Zelda Classic Coverage Report


Directory: src/
File: src/zc/zc_sys.cpp
Date: 2023-03-18 18:24:01
Exec Total Coverage
Lines: 1779 4261 41.8%
Functions: 128 342 37.4%
Branches: 953 2690 35.4%

Line Branch Exec Source
1 //--------------------------------------------------------
2 // Zelda Classic
3 // by Jeremy Craner, 1999-2000
4 //
5 // zc_sys.cc
6 //
7 // System functions, input handlers, GUI stuff, etc.
8 // for Zelda Classic.
9 //
10 //--------------------------------------------------------
11
12 // to prevent <map> from generating errors
13 #define __GTHREAD_HIDE_WIN32API 1
14
15 #include "precompiled.h" //always first
16 #include "zc_sys.h"
17
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29
18 #include <stdio.h>
19 #include <stdlib.h>
20 #include <string.h>
21 #include <math.h>
22 #include <map>
23 #include <filesystem>
24 #include <ctype.h>
25 #include <sstream>
26 #include "base/zc_alleg.h"
27 #include "gamedata.h"
28 #include "zc_init.h"
29 #include "init.h"
30 #include "replay.h"
31 #include "cheats.h"
32 #include "render.h"
33 #include "base/zc_math.h"
34 #include "base/zapp.h"
35 #include "dialog/cheatkeys.h"
36
37 #ifdef ALLEGRO_DOS
38 #include <unistd.h>
39 #endif
40
41 #include "metadata/metadata.h"
42 #include "zelda.h"
43 #include "tiles.h"
44 #include "base/colors.h"
45 #include "pal.h"
46 #include "base/zsys.h"
47 #include "qst.h"
48 #include "zc_sys.h"
49 #include "play_midi.h"
50 #include "debug.h"
51 #include "jwin_a5.h"
52 #include "base/jwinfsel.h"
53 #include "base/gui.h"
54 #include "midi.h"
55 #include "subscr.h"
56 #include "maps.h"
57 #include "sprite.h"
58 #include "guys.h"
59 #include "hero.h"
60 #include "title.h"
61 #include "particles.h"
62 #include "zconsole.h"
63 #include "ffscript.h"
64 #include "dialog/info.h"
65 #include "dialog/alert.h"
66 #include <fmt/format.h>
67
68 #ifdef __EMSCRIPTEN__
69 #include "base/emscripten_utils.h"
70 #endif
71
72 extern FFScript FFCore;
73 extern bool Playing;
74 int32_t sfx_voice[WAV_COUNT];
75 int32_t d_stringloader(int32_t msg,DIALOG *d,int32_t c);
76 int32_t d_midilist_proc(int32_t msg,DIALOG *d,int32_t c);
77
78 extern byte monochrome_console;
79
80 extern FONT *lfont;
81 extern HeroClass Hero;
82 extern FFScript FFCore;
83 extern ZModule zcm;
84 extern zcmodule moduledata;
85 extern sprite_list guys, items, Ewpns, Lwpns, Sitems, chainlinks, decorations;
86 extern particle_list particles;
87 extern int32_t loadlast;
88 extern word passive_subscreen_doscript;
89 extern bool passive_subscreen_waitdraw;
90 extern char *sfx_string[WAV_COUNT];
91 byte use_dwm_flush;
92 byte use_save_indicator;
93 byte midi_patch_fix;
94 bool midi_paused=false;
95 int32_t paused_midi_pos = 0;
96 byte midi_suspended = 0;
97 byte callback_switchin = 0;
98 byte zc_192b163_warp_compatibility;
99 char modulepath[2048];
100 bool epilepsyFlashReduction;
101 signed char pause_in_background_menu_init = 0;
102 byte pause_in_background = 0;
103 bool is_sys_pal = false;
104 static bool load_control_called_this_frame;
105 extern PALETTE* hw_palette;
106 extern bool update_hw_pal;
107 extern const char* dmaplist(int32_t index, int32_t* list_size);
108 int32_t getnumber(const char *prompt,int32_t initialval);
109
110 extern bool kb_typing_mode; //script only, for disbaling key presses affecting Hero, etc.
111 extern int32_t cheat_modifier_keys[4]; //two options each, default either control and either shift
112 //extern byte refresh_select_screen;
113 //extern movingblock mblock2; //mblock[4]?
114 //extern int32_t db;
115
116 static const char *ZC_str = "Zelda Classic";
117 extern char save_file_name[1024];
118 #ifdef ALLEGRO_DOS
119 const char *qst_dir_name = "dos_qst_dir";
120 #elif defined(ALLEGRO_WINDOWS)
121 const char *qst_dir_name = "win_qst_dir";
122 static const char *qst_module_name = "current_module";
123 #elif defined(ALLEGRO_LINUX)
124 const char *qst_dir_name = "linux_qst_dir";
125 static const char *qst_module_name = "current_module";
126 #elif defined(__APPLE__)
127 const char *qst_dir_name = "osx_qst_dir";
128 static const char *qst_module_name = "current_module";
129 #endif
130 #ifdef ALLEGRO_LINUX
131 static const char *samplepath = "samplesoundset/patches.dat";
132 #endif
133 char qst_files_path[2048];
134
135 #ifdef _MSC_VER
136 #define getcwd _getcwd
137 #endif
138
139 bool rF11();
140 bool rI();
141 bool rQ();
142 bool zc_key_pressed();
143
144 #ifdef _WIN32
145
146 // This should only be necessary for MinGW, since it doesn't have a dwmapi.h. Add another #ifdef if you like.
147 extern "C"
148 {
149 typedef HRESULT(WINAPI *t_DwmFlush)();
150 typedef HRESULT(WINAPI *t_DwmIsCompositionEnabled)(BOOL *pfEnabled);
151 }
152
153 void do_DwmFlush()
154 {
155 static HMODULE shell = LoadLibrary("dwmapi.dll");
156
157 if(!shell)
158 return;
159
160 static t_DwmFlush flush=reinterpret_cast<t_DwmFlush>(GetProcAddress(shell, "DwmFlush"));
161 static t_DwmIsCompositionEnabled isEnabled=reinterpret_cast<t_DwmIsCompositionEnabled>(GetProcAddress(shell, "DwmIsCompositionEnabled"));
162
163 BOOL enabled;
164 isEnabled(&enabled);
165
166 if(isEnabled)
167 flush();
168 }
169
170 #endif // _WIN32
171
172 82019 bool flash_reduction_enabled(bool check_qr)
173 {
174
4/4
✓ Branch 0 taken 79798 times.
✓ Branch 1 taken 2221 times.
✓ Branch 2 taken 79342 times.
✓ Branch 3 taken 81563 times.
82019 return (check_qr && get_bit(quest_rules, qr_EPILEPSY)) || epilepsyFlashReduction || replay_is_debug();
175 }
176
177 // Dialogue largening
178 void large_dialog(DIALOG *d)
179 {
180 large_dialog(d, 1.5);
181 }
182
183 void large_dialog(DIALOG *d, float RESIZE_AMT)
184 {
185 if(!d[0].d1)
186 {
187 d[0].d1 = 1;
188 int32_t oldwidth = d[0].w;
189 int32_t oldheight = d[0].h;
190 int32_t oldx = d[0].x;
191 int32_t oldy = d[0].y;
192 d[0].x -= int32_t(d[0].w/RESIZE_AMT);
193 d[0].y -= int32_t(d[0].h/RESIZE_AMT);
194 d[0].w = int32_t(d[0].w*RESIZE_AMT);
195 d[0].h = int32_t(d[0].h*RESIZE_AMT);
196
197 for(int32_t i=1; d[i].proc !=NULL; i++)
198 {
199 // Place elements horizontally
200 double xpc = ((double)(d[i].x - oldx) / (double)oldwidth);
201 d[i].x = int32_t(d[0].x + (xpc*d[0].w));
202
203 if(d[i].proc != d_stringloader)
204 {
205 if(d[i].proc==d_bitmap_proc)
206 {
207 d[i].w *= 2;
208 }
209 else d[i].w = int32_t(d[i].w*RESIZE_AMT);
210 }
211
212 // Place elements vertically
213 double ypc = ((double)(d[i].y - oldy) / (double)oldheight);
214 d[i].y = int32_t(d[0].y + (ypc*d[0].h));
215
216 // Vertically resize elements
217 if(d[i].proc == jwin_edit_proc || d[i].proc == jwin_check_proc || d[i].proc == jwin_checkfont_proc)
218 {
219 d[i].h = int32_t((double)d[i].h*1.5);
220 }
221 else if(d[i].proc == jwin_droplist_proc)
222 {
223 d[i].y += int32_t((double)d[i].h*0.25);
224 d[i].h = int32_t((double)d[i].h*1.25);
225 }
226 else if(d[i].proc==d_bitmap_proc)
227 {
228 d[i].h *= 2;
229 }
230 else d[i].h = int32_t(d[i].h*RESIZE_AMT);
231
232 // Fix frames
233 if(d[i].proc == jwin_frame_proc)
234 {
235 d[i].x++;
236 d[i].y++;
237 d[i].w-=4;
238 d[i].h-=4;
239 }
240 }
241 }
242
243 for(int32_t i=1; d[i].proc!=NULL; i++)
244 {
245 if(d[i].proc==jwin_slider_proc)
246 continue;
247
248 // Bigger font
249 bool bigfontproc = (d[i].proc != d_midilist_proc && d[i].proc != jwin_droplist_proc && d[i].proc != jwin_abclist_proc && d[i].proc != jwin_list_proc);
250
251 if(!d[i].dp2 && bigfontproc)
252 {
253 //d[i].dp2 = (d[i].proc == jwin_edit_proc) ? sfont3 : lfont_l;
254 d[i].dp2 = lfont_l;
255 }
256 else if(!bigfontproc)
257 {
258 // ((ListData *)d[i].dp)->font = &sfont3;
259 ((ListData *)d[i].dp)->font = &lfont_l;
260 }
261
262 // Make checkboxes work
263 if(d[i].proc == jwin_check_proc)
264 d[i].proc = jwin_checkfont_proc;
265 else if(d[i].proc == jwin_radio_proc)
266 d[i].proc = jwin_radiofont_proc;
267 }
268
269 jwin_center_dialog(d);
270 }
271
272
273 /**********************************/
274 /******** System functions ********/
275 /**********************************/
276
277 static char cfg_sect[] = "zeldadx"; //We need to rename this.
278 static char ctrl_sect[] = "Controls";
279 static char sfx_sect[] = "Volume";
280
281 int32_t d_dummy_proc(int32_t,DIALOG *,int32_t)
282 {
283 return D_O_K;
284 }
285
286 bool checkcheat(Cheat cheat)
287 {
288 if(cheatkeys[cheat][0] && zc_readkey(cheatkeys[cheat][0]))
289 return true; //Main key pressed
290 if(cheatkeys[cheat][1] && zc_readkey(cheatkeys[cheat][1]))
291 return true; //Alt key pressed
292 return false;
293 }
294 29 void load_default_cheatkeys()
295 {
296 29 memset(cheatkeys, 0, sizeof(cheatkeys));
297 29 cheatkeys[Cheat::Life][0] = KEY_H;
298 29 cheatkeys[Cheat::Life][1] = KEY_ASTERISK;
299 29 cheatkeys[Cheat::Magic][0] = KEY_M;
300 29 cheatkeys[Cheat::Magic][1] = KEY_SLASH_PAD;
301 29 cheatkeys[Cheat::Rupies][0] = KEY_R;
302 29 cheatkeys[Cheat::Bombs][0] = KEY_B;
303 29 cheatkeys[Cheat::Arrows][0] = KEY_A;
304 29 cheatkeys[Cheat::Clock][0] = KEY_I;
305 29 cheatkeys[Cheat::Walls][0] = KEY_F11;
306 29 cheatkeys[Cheat::Fast][0] = KEY_Q;
307 29 cheatkeys[Cheat::Light][0] = KEY_L;
308 29 cheatkeys[Cheat::IgnoreSideView][0] = KEY_V;
309 29 cheatkeys[Cheat::Kill][0] = KEY_K;
310 29 cheatkeys[Cheat::GoTo][0] = KEY_G;
311 29 cheatkeys[Cheat::TrigSecrets][0] = KEY_S;
312 29 cheatkeys[Cheat::ShowL0][0] = KEY_0;
313 29 cheatkeys[Cheat::ShowL1][0] = KEY_1;
314 29 cheatkeys[Cheat::ShowL2][0] = KEY_2;
315 29 cheatkeys[Cheat::ShowL3][0] = KEY_3;
316 29 cheatkeys[Cheat::ShowL4][0] = KEY_4;
317 29 cheatkeys[Cheat::ShowL5][0] = KEY_5;
318 29 cheatkeys[Cheat::ShowL6][0] = KEY_6;
319 29 cheatkeys[Cheat::ShowFFC][0] = KEY_7;
320 29 cheatkeys[Cheat::ShowSprites][0] = KEY_8;
321 29 cheatkeys[Cheat::ShowWalkability][0] = KEY_W;
322 29 cheatkeys[Cheat::ShowEffects][0] = KEY_E;
323 29 cheatkeys[Cheat::ShowOverhead][0] = KEY_O;
324 29 cheatkeys[Cheat::ShowPushblock][0] = KEY_P;
325 29 cheatkeys[Cheat::ShowHitbox][0] = KEY_C;
326 29 cheatkeys[Cheat::ShowFFCScripts][0] = KEY_F;
327 29 }
328 29 void load_game_configs()
329 {
330 29 strcpy(moduledata.module_name,zc_get_config("ZCMODULE",qst_module_name,"classic.zmod"));
331 29 joystick_index = zc_get_config(ctrl_sect,"joystick_index",0);
332 29 js_stick_1_x_stick = zc_get_config(ctrl_sect,"js_stick_1_x_stick",0);
333 29 js_stick_1_x_axis = zc_get_config(ctrl_sect,"js_stick_1_x_axis",0);
334 29 js_stick_1_x_offset = zc_get_config(ctrl_sect,"js_stick_1_x_offset",0) ? 128 : 0;
335 29 js_stick_1_y_stick = zc_get_config(ctrl_sect,"js_stick_1_y_stick",0);
336 29 js_stick_1_y_axis = zc_get_config(ctrl_sect,"js_stick_1_y_axis",1);
337 29 js_stick_1_y_offset = zc_get_config(ctrl_sect,"js_stick_1_y_offset",0) ? 128 : 0;
338 29 js_stick_2_x_stick = zc_get_config(ctrl_sect,"js_stick_2_x_stick",1);
339 29 js_stick_2_x_axis = zc_get_config(ctrl_sect,"js_stick_2_x_axis",0);
340 29 js_stick_2_x_offset = zc_get_config(ctrl_sect,"js_stick_2_x_offset",0) ? 128 : 0;
341 29 js_stick_2_y_stick = zc_get_config(ctrl_sect,"js_stick_2_y_stick",1);
342 29 js_stick_2_y_axis = zc_get_config(ctrl_sect,"js_stick_2_y_axis",1);
343 29 js_stick_2_y_offset = zc_get_config(ctrl_sect,"js_stick_2_y_offset",0) ? 128 : 0;
344 29 analog_movement = (zc_get_config(ctrl_sect,"analog_movement",1));
345
346 //cheat modifier keya
347 29 cheat_modifier_keys[0] = zc_get_config(ctrl_sect,"key_cheatmod_a1",KEY_ZC_LCONTROL);
348 29 cheat_modifier_keys[1] = zc_get_config(ctrl_sect,"key_cheatmod_a2",0);
349 29 cheat_modifier_keys[2] = zc_get_config(ctrl_sect,"key_cheatmod_b1",KEY_ZC_RCONTROL);
350 29 cheat_modifier_keys[3] = zc_get_config(ctrl_sect,"key_cheatmod_b2",0);
351
352 //cheat keys
353 29 load_default_cheatkeys();
354 char buf[256];
355 29 al_trace("START CHEATS\n");
356
2/2
✓ Branch 0 taken 1015 times.
✓ Branch 1 taken 29 times.
1044 for(size_t q = 1; q < Cheat::Last; ++q)
357 {
358
1/2
✓ Branch 0 taken 1015 times.
✗ Branch 1 not taken.
1015 if(!bindable_cheat((Cheat)q)) continue;
359 1015 std::string cheatname = cheat_to_string((Cheat)q);
360
1/2
✓ Branch 0 taken 1015 times.
✗ Branch 1 not taken.
1015 util::lowerstr(cheatname);
361 1015 sprintf(buf, "key_cheat_%s_main", cheatname.c_str());
362
1/2
✓ Branch 0 taken 1015 times.
✗ Branch 1 not taken.
1015 al_trace("%s = %d\n", buf, cheatkeys[q][0]);
363
1/2
✓ Branch 0 taken 1015 times.
✗ Branch 1 not taken.
1015 cheatkeys[q][0] = zc_get_config(ctrl_sect,buf,cheatkeys[q][0]);
364 1015 sprintf(buf, "key_cheat_%s_alt", cheatname.c_str());
365
1/2
✓ Branch 0 taken 1015 times.
✗ Branch 1 not taken.
1015 al_trace("%s = %d\n", buf, cheatkeys[q][1]);
366
1/2
✓ Branch 0 taken 1015 times.
✗ Branch 1 not taken.
1015 cheatkeys[q][1] = zc_get_config(ctrl_sect,buf,cheatkeys[q][1]);
367 1015 }
368 29 al_trace("END CHEATS\n");
369
370
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if((uint32_t)joystick_index >= MAX_JOYSTICKS)
371 joystick_index = 0;
372
373 29 Akey = zc_get_config(ctrl_sect,"key_a",KEY_Z);
374 29 Bkey = zc_get_config(ctrl_sect,"key_b",KEY_X);
375 29 Skey = zc_get_config(ctrl_sect,"key_s",KEY_ENTER);
376 29 Lkey = zc_get_config(ctrl_sect,"key_l",KEY_Q);
377 29 Rkey = zc_get_config(ctrl_sect,"key_r",KEY_W);
378 29 Pkey = zc_get_config(ctrl_sect,"key_p",KEY_SPACE);
379 29 Exkey1 = zc_get_config(ctrl_sect,"key_ex1",KEY_A);
380 29 Exkey2 = zc_get_config(ctrl_sect,"key_ex2",KEY_S);
381 29 Exkey3 = zc_get_config(ctrl_sect,"key_ex3",KEY_D);
382 29 Exkey4 = zc_get_config(ctrl_sect,"key_ex4",KEY_C);
383
384 29 DUkey = zc_get_config(ctrl_sect,"key_up", KEY_UP);
385 29 DDkey = zc_get_config(ctrl_sect,"key_down", KEY_DOWN);
386 29 DLkey = zc_get_config(ctrl_sect,"key_left", KEY_LEFT);
387 29 DRkey = zc_get_config(ctrl_sect,"key_right",KEY_RIGHT);
388
389 29 Abtn = zc_get_config(ctrl_sect,"btn_a",2);
390 29 Bbtn = zc_get_config(ctrl_sect,"btn_b",1);
391 29 Sbtn = zc_get_config(ctrl_sect,"btn_s",10);
392 29 Mbtn = zc_get_config(ctrl_sect,"btn_m",9);
393 29 Lbtn = zc_get_config(ctrl_sect,"btn_l",5);
394 29 Rbtn = zc_get_config(ctrl_sect,"btn_r",6);
395 29 Pbtn = zc_get_config(ctrl_sect,"btn_p",12);
396 29 Exbtn1 = zc_get_config(ctrl_sect,"btn_ex1",7);
397 29 Exbtn2 = zc_get_config(ctrl_sect,"btn_ex2",8);
398 29 Exbtn3 = zc_get_config(ctrl_sect,"btn_ex3",4);
399 29 Exbtn4 = zc_get_config(ctrl_sect,"btn_ex4",3);
400
401 29 DUbtn = zc_get_config(ctrl_sect,"btn_up",13);
402 29 DDbtn = zc_get_config(ctrl_sect,"btn_down",14);
403 29 DLbtn = zc_get_config(ctrl_sect,"btn_left",15);
404 29 DRbtn = zc_get_config(ctrl_sect,"btn_right",16);
405
406 29 epilepsyFlashReduction = zc_get_config(cfg_sect,"epilepsy_flash_reduction",0);
407
408 29 digi_volume = zc_get_config(sfx_sect,"digi",248);
409 29 midi_volume = zc_get_config(sfx_sect,"midi",255);
410 29 sfx_volume = zc_get_config(sfx_sect,"sfx",248);
411 29 emusic_volume = zc_get_config(sfx_sect,"emusic",248);
412 29 pan_style = zc_get_config(sfx_sect,"pan",1);
413 // 1 <= zcmusic_bufsz <= 128
414 29 zcmusic_bufsz = vbound(zc_get_config(sfx_sect,"zcmusic_bufsz",64),1,128);
415 29 volkeys = zc_get_config(sfx_sect,"volkeys",0)!=0;
416 29 zc_vsync = zc_get_config(cfg_sect,"vsync",0);
417 29 Throttlefps = zc_get_config(cfg_sect,"throttlefps",1)!=0;
418 29 TransLayers = zc_get_config(cfg_sect,"translayers",1)!=0;
419 29 SnapshotFormat = zc_get_config(cfg_sect,"snapshot_format",3);
420 29 NameEntryMode = zc_get_config(cfg_sect,"name_entry_mode",0);
421 #ifdef __EMSCRIPTEN__
422 if (em_is_mobile()) NameEntryMode = 2;
423 #endif
424 29 ShowFPS = zc_get_config(cfg_sect,"showfps",0)!=0;
425 29 NESquit = zc_get_config(cfg_sect,"fastquit",0)!=0;
426 29 ClickToFreeze = zc_get_config(cfg_sect,"clicktofreeze",1)!=0;
427 29 title_version = zc_get_config(cfg_sect,"title",2);
428 29 abc_patternmatch = zc_get_config(cfg_sect, "lister_pattern_matching", 1);
429 29 pause_in_background = zc_get_config(cfg_sect, "pause_in_background", 0);
430
431 //default - scale x2, 640 x 480
432 29 window_width = resx = zc_get_config(cfg_sect,"window_width",640);
433 29 window_height = resy = zc_get_config(cfg_sect,"window_height",480);
434 29 SaveDragResize = zc_get_config(cfg_sect,"save_drag_resize",0)!=0;
435 29 DragAspect = zc_get_config(cfg_sect,"drag_aspect",0)!=0;
436 29 SaveWinPos = zc_get_config(cfg_sect,"save_window_position",0)!=0;
437
438 29 loadlast = zc_get_config(cfg_sect,"load_last",0);
439
440 29 fullscreen = zc_get_config(cfg_sect,"fullscreen",0);
441
442 29 zc_color_depth = (byte) zc_get_config(cfg_sect,"color_depth",8);
443
444 29 forceExit = (byte) zc_get_config(cfg_sect,"force_exit",0);
445 29 info_opacity = zc_get_config("zc","debug_info_opacity",255);
446 #ifdef _WIN32
447 zasm_debugger = (byte) zc_get_config("CONSOLE","print_ZASM",0);
448 zscript_debugger = (byte) zc_get_config("CONSOLE","ZScript_Debugger",0);
449 //use_win7_keyboard_fix = (byte) zc_get_config(cfg_sect,"use_win7_key_fix",0);
450 use_win32_proc = (byte) zc_get_config(cfg_sect,"zc_win_proc_fix",0); //buggy
451
452 // This one's for Aero
453 use_dwm_flush = (byte) zc_get_config("zeldadx","use_dwm_flush",0);
454
455 // And this one fixes patches unloading on some MIDI setups
456 midi_patch_fix = (byte) zc_get_config("zeldadx","midi_patch_fix",1);
457 monochrome_console = (byte) zc_get_config("CONSOLE","monochrome_debuggers",0);
458 #else //UNIX
459 29 zasm_debugger = (byte) zc_get_config("CONSOLE","print_ZASM",0);
460 29 zscript_debugger = (byte) zc_get_config("CONSOLE","ZScript_Debugger",0);
461 29 monochrome_console = (byte) zc_get_config("CONSOLE","monochrome_debuggers",0);
462 #endif
463 29 clearConsoleOnLoad = zc_get_config("CONSOLE","clear_console_on_load",1)!=0;
464 29 clearConsoleOnReload = zc_get_config("CONSOLE","clear_console_on_reload",0)!=0;
465
466 29 char const* default_path = "";
467 29 strcpy(qstdir,zc_get_config(cfg_sect,qst_dir_name,default_path));
468
469
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
29 if(strlen(qstdir)==0)
470 {
471 29 getcwd(qstdir,2048);
472 29 fix_filename_case(qstdir);
473 29 fix_filename_slashes(qstdir);
474 29 put_backslash(qstdir);
475 29 }
476 else
477 {
478 chop_path(qstdir);
479 }
480
481 29 strcpy(qstpath,qstdir); //qstpath is the local (for this run of ZC) quest path, qstdir is the universal quest dir.
482 29 ss_enable = zc_get_config(cfg_sect,"ss_enable",1) ? 1 : 0;
483 29 ss_after = vbound(zc_get_config(cfg_sect,"ss_after",14), 0, 14);
484 29 ss_speed = vbound(zc_get_config(cfg_sect,"ss_speed",2), 0, 6);
485 29 ss_density = vbound(zc_get_config(cfg_sect,"ss_density",3), 0, 6);
486 29 heart_beep = zc_get_config(cfg_sect,"heart_beep",1)!=0;
487 //gui_colorset = zc_get_config(cfg_sect,"gui_colorset",0);
488 29 sfxdat = zc_get_config(cfg_sect,"use_sfx_dat",1);
489 29 fullscreen = zc_get_config(cfg_sect,"fullscreen",0);
490 29 use_save_indicator = zc_get_config(cfg_sect,"save_indicator",0);
491 29 zc_192b163_warp_compatibility = zc_get_config(cfg_sect,"zc_192b163_warp_compatibility",0);
492 29 }
493
494 void save_control_configs(bool kb)
495 {
496 if(kb)
497 {
498 zc_set_config(ctrl_sect,"key_cheatmod_a1",cheat_modifier_keys[0]);
499 zc_set_config(ctrl_sect,"key_cheatmod_a2",cheat_modifier_keys[1]);
500 zc_set_config(ctrl_sect,"key_cheatmod_b1",cheat_modifier_keys[2]);
501 zc_set_config(ctrl_sect,"key_cheatmod_b2",cheat_modifier_keys[3]);
502
503 if (!replay_is_replaying())
504 {
505 zc_set_config(ctrl_sect,"key_a",Akey);
506 zc_set_config(ctrl_sect,"key_b",Bkey);
507 zc_set_config(ctrl_sect,"key_s",Skey);
508 zc_set_config(ctrl_sect,"key_l",Lkey);
509 zc_set_config(ctrl_sect,"key_r",Rkey);
510 zc_set_config(ctrl_sect,"key_p",Pkey);
511 zc_set_config(ctrl_sect,"key_ex1",Exkey1);
512 zc_set_config(ctrl_sect,"key_ex2",Exkey2);
513 zc_set_config(ctrl_sect,"key_ex3",Exkey3);
514 zc_set_config(ctrl_sect,"key_ex4",Exkey4);
515 zc_set_config(ctrl_sect,"key_up", DUkey);
516 zc_set_config(ctrl_sect,"key_down", DDkey);
517 zc_set_config(ctrl_sect,"key_left", DLkey);
518 zc_set_config(ctrl_sect,"key_right",DRkey);
519 }
520 }
521 else
522 {
523 zc_set_config(ctrl_sect,"joystick_index",joystick_index);
524 zc_set_config(ctrl_sect,"js_stick_1_x_stick",js_stick_1_x_stick);
525 zc_set_config(ctrl_sect,"js_stick_1_x_axis",js_stick_1_x_axis);
526 zc_set_config(ctrl_sect,"js_stick_1_x_offset",js_stick_1_x_offset ? 1 : 0);
527 zc_set_config(ctrl_sect,"js_stick_1_y_stick",js_stick_1_y_stick);
528 zc_set_config(ctrl_sect,"js_stick_1_y_axis",js_stick_1_y_axis);
529 zc_set_config(ctrl_sect,"js_stick_1_y_offset",js_stick_1_y_offset ? 1 : 0);
530 zc_set_config(ctrl_sect,"js_stick_2_x_stick",js_stick_2_x_stick);
531 zc_set_config(ctrl_sect,"js_stick_2_x_axis",js_stick_2_x_axis);
532 zc_set_config(ctrl_sect,"js_stick_2_x_offset",js_stick_2_x_offset ? 1 : 0);
533 zc_set_config(ctrl_sect,"js_stick_2_y_stick",js_stick_2_y_stick);
534 zc_set_config(ctrl_sect,"js_stick_2_y_axis",js_stick_2_y_axis);
535 zc_set_config(ctrl_sect,"js_stick_2_y_offset",js_stick_2_y_offset ? 1 : 0);
536 zc_set_config(ctrl_sect,"analog_movement",analog_movement);
537
538 zc_set_config(ctrl_sect,"btn_a",Abtn);
539 zc_set_config(ctrl_sect,"btn_b",Bbtn);
540 zc_set_config(ctrl_sect,"btn_s",Sbtn);
541 zc_set_config(ctrl_sect,"btn_m",Mbtn);
542 zc_set_config(ctrl_sect,"btn_l",Lbtn);
543 zc_set_config(ctrl_sect,"btn_r",Rbtn);
544 zc_set_config(ctrl_sect,"btn_p",Pbtn);
545 zc_set_config(ctrl_sect,"btn_ex1",Exbtn1);
546 zc_set_config(ctrl_sect,"btn_ex2",Exbtn2);
547 zc_set_config(ctrl_sect,"btn_ex3",Exbtn3);
548 zc_set_config(ctrl_sect,"btn_ex4",Exbtn4);
549
550 zc_set_config(ctrl_sect,"btn_up",DUbtn);
551 zc_set_config(ctrl_sect,"btn_down",DDbtn);
552 zc_set_config(ctrl_sect,"btn_left",DLbtn);
553 zc_set_config(ctrl_sect,"btn_right",DRbtn);
554 }
555 }
556
557 void save_cheatkeys()
558 {
559 char buf[256];
560 for(size_t q = 1; q < Cheat::Last; ++q)
561 {
562 if(!bindable_cheat((Cheat)q)) continue;
563 std::string cheatname = cheat_to_string((Cheat)q);
564 util::lowerstr(cheatname);
565 sprintf(buf, "key_cheat_%s_main", cheatname.c_str());
566 zc_set_config(ctrl_sect,buf,cheatkeys[q][0]);
567 sprintf(buf, "key_cheat_%s_alt", cheatname.c_str());
568 if(cheatkeys[q][1])
569 zc_set_config(ctrl_sect,buf,cheatkeys[q][1]);
570 else zc_set_config(ctrl_sect,buf,(char*)nullptr);
571 }
572 }
573
574 void save_game_configs()
575 {
576 packfile_password("");
577
578 zc_set_config("ZCMODULE",qst_module_name,moduledata.module_name);
579
580 if (all_get_display() && !all_get_fullscreen_flag()&& SaveWinPos)
581 {
582 int o_window_x, o_window_y;
583 al_get_window_position(all_get_display(), &o_window_x, &o_window_y);
584 zc_set_config(cfg_sect,"window_x",o_window_x);
585 zc_set_config(cfg_sect,"window_y",o_window_y);
586 }
587
588 if (all_get_display() && !all_get_fullscreen_flag() && SaveDragResize)
589 {
590 double monitor_scale = zc_get_monitor_scale();
591 window_width = al_get_display_width(all_get_display()) / monitor_scale;
592 window_height = al_get_display_height(all_get_display()) / monitor_scale;
593 zc_set_config(cfg_sect,"window_width",window_width);
594 zc_set_config(cfg_sect,"window_height",window_height);
595 }
596
597 zc_set_config(cfg_sect,"load_last",loadlast);
598 chop_path(qstdir);
599 zc_set_config(cfg_sect,qst_dir_name,qstdir);
600 zc_set_config("SAVEFILE","save_filename",save_file_name);
601 zc_set_config(cfg_sect,"use_sfx_dat",sfxdat);
602
603 flush_config_file();
604 #ifdef __EMSCRIPTEN__
605 em_sync_fs();
606 #endif
607 }
608
609 //----------------------------------------------------------------
610
611 // Timers
612
613 28085 void fps_callback()
614 {
615 28085 lastfps=framecnt;
616 28085 dword tempsecs = fps_secs;
617 28085 ++tempsecs;
618 //avgfps=((long double)avgfps*fps_secs+lastfps)/(++fps_secs); // DJGPP doesn't like this
619 28085 avgfps=((long double)avgfps*fps_secs+lastfps)/(tempsecs);
620 28085 ++fps_secs;
621 28085 framecnt=0;
622 28085 }
623
624 END_OF_FUNCTION(fps_callback)
625
626 29 int32_t Z_init_timers()
627 {
628 static bool didit = false;
629 const static char *err_str = "Couldn't allocate timer";
630 29 err_str = err_str; //Unused variable warning
631
632
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
29 if(didit)
633 return 1;
634
635 29 didit = true;
636
637 LOCK_VARIABLE(lastfps);
638 LOCK_VARIABLE(framecnt);
639 LOCK_FUNCTION(fps_callback);
640
641
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(install_int_ex(fps_callback,SECS_TO_TIMER(1)))
642 return 0;
643
644 29 return 1;
645 29 }
646
647 void Z_remove_timers()
648 {
649 remove_int(fps_callback);
650 }
651
652 //----------------------------------------------------------------
653
654 void go()
655 {
656 scare_mouse();
657 blit(screen,tmp_scr,scrx,scry,0,0,screen->w,screen->h);
658 unscare_mouse();
659 }
660
661 void comeback()
662 {
663 scare_mouse();
664 blit(tmp_scr,screen,0,0,scrx,scry,screen->w,screen->h);
665 unscare_mouse();
666 }
667
668 void dump_pal(BITMAP *dest)
669 {
670 for(int32_t i=0; i<256; i++)
671 rectfill(dest,(i&63)<<2,(i&0xFC0)>>4,((i&63)<<2)+3,((i&0xFC0)>>4)+3,i);
672 }
673
674 //----------------------------------------------------------------
675
676 //Handles converting the mouse sprite from the .dat file
677 29 void load_mouse()
678 {
679 29 system_pal();
680 29 scare_mouse();
681 29 set_mouse_sprite(NULL);
682 29 int32_t sz = vbound(int32_t(16*(zc_get_config("zeldadx","cursor_scale_large",1.5))),16,80);
683
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 29 times.
145 for(int32_t j = 0; j < 4; ++j)
684 {
685 116 BITMAP* tmpbmp = create_bitmap_ex(8,16,16);
686 116 BITMAP* subbmp = create_bitmap_ex(8,16,16);
687
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(zcmouse[j])
688 destroy_bitmap(zcmouse[j]);
689 116 zcmouse[j] = create_bitmap_ex(8,sz,sz);
690 116 clear_bitmap(zcmouse[j]);
691 116 clear_bitmap(tmpbmp);
692 116 clear_bitmap(subbmp);
693 116 blit((BITMAP*)datafile[BMP_MOUSE].dat,tmpbmp,1,j*17+1,0,0,16,16);
694
2/2
✓ Branch 0 taken 1856 times.
✓ Branch 1 taken 116 times.
1972 for(int32_t x = 0; x < 16; ++x)
695 {
696
2/2
✓ Branch 0 taken 29696 times.
✓ Branch 1 taken 1856 times.
31552 for(int32_t y = 0; y < 16; ++y)
697 {
698 29696 int32_t color = getpixel(tmpbmp, x, y);
699
5/5
✓ Branch 0 taken 27318 times.
✓ Branch 1 taken 551 times.
✓ Branch 2 taken 638 times.
✓ Branch 3 taken 667 times.
✓ Branch 4 taken 522 times.
29696 switch(color)
700 {
701 case dvc(1):
702 551 color = jwin_pal[jcCURSORMISC];
703 551 break;
704 case dvc(2):
705 638 color = jwin_pal[jcCURSOROUTLINE];
706 638 break;
707 case dvc(3):
708 667 color = jwin_pal[jcCURSORLIGHT];
709 667 break;
710 case dvc(5):
711 522 color = jwin_pal[jcCURSORDARK];
712 522 break;
713 }
714 29696 putpixel(subbmp, x, y, color);
715 29696 }
716 1856 }
717
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(sz!=16)
718 116 stretch_blit(subbmp, zcmouse[j], 0, 0, 16, 16, 0, 0, sz, sz);
719 else
720 blit(subbmp, zcmouse[j], 0, 0, 0, 0, 16, 16);
721 116 destroy_bitmap(tmpbmp);
722 116 destroy_bitmap(subbmp);
723 116 }
724 29 set_mouse_sprite(zcmouse[0]);
725
726 // Must attempt to show cursor for allegro 5 to render it with the associated palette.
727 29 set_palette(*hw_palette);
728 29 show_mouse(screen);
729 29 show_mouse(NULL);
730
731 29 unscare_mouse();
732 29 game_pal();
733 29 }
734
735 // sets the video mode and initializes the palette and mouse sprite
736 29 bool game_vid_mode(int32_t mode,int32_t wait)
737 {
738
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
29 if(set_gfx_mode(mode,resx,resy,0,0)!=0)
739 {
740 return false;
741 }
742
743 29 scrx = (resx-320)>>1;
744 29 scry = (resy-240)>>1;
745
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 29 times.
145 for(int32_t q = 0; q < 4; ++q)
746 116 zcmouse[q] = NULL;
747 29 load_mouse();
748 29 set_mouse_sprite(zcmouse[0]);
749
750
2/2
✓ Branch 0 taken 464 times.
✓ Branch 1 taken 29 times.
493 for(int32_t i=240; i<256; i++)
751 464 RAMpal[i]=((RGB*)datafile[PAL_GUI].dat)[i];
752
753 29 set_palette(RAMpal);
754 29 clear_to_color(screen,BLACK);
755
756 29 rest(wait);
757 29 return true;
758 29 }
759
760 5 void null_quest()
761 {
762 char qstdat_string[2048];
763 5 strcpy(qstdat_string,moduledata.datafiles[qst_dat]);
764 5 strcat(qstdat_string,"#NESQST_NEW_QST");
765
766 #ifdef __EMSCRIPTEN__
767 // The quest template data file is not included because it's really big and isn't really needed
768 // for the player, except to initialize some graphics. Those same graphics exist in this quest file,
769 // which is much smaller.
770 strcpy(qstdat_string, "modules/classic/title_gfx.dat");
771 #endif
772
773 5 byte skip_flags[4] = { 0 };
774
775 5 loadquest(qstdat_string,&QHeader,&QMisc,tunes+ZC_MIDI_COUNT,false,true,true,true,skip_flags,0,false);
776 5 }
777
778 5 void init_NES_mode()
779 {
780 /*
781 // qst.dat may not load correctly without this...
782 QHeader.templatepath[0]='\0';
783
784 if(!init_colordata(true, &QHeader, &QMisc))
785 {
786 return;
787 }
788
789 loadfullpal();
790 init_tiles(false, &QHeader);
791 */
792 5 null_quest();
793 5 }
794
795 //----------------------------------------------------------------
796
797 qword trianglelines[16]=
798 {
799 0x0000000000000000ULL,
800 0xFD00000000000000ULL,
801 0xFDFD000000000000ULL,
802 0xFDFDFD0000000000ULL,
803 0xFDFDFDFD00000000ULL,
804 0xFDFDFDFDFD000000ULL,
805 0xFDFDFDFDFDFD0000ULL,
806 0xFDFDFDFDFDFDFD00ULL,
807 0xFDFDFDFDFDFDFDFDULL,
808 0x00FDFDFDFDFDFDFDULL,
809 0x0000FDFDFDFDFDFDULL,
810 0x000000FDFDFDFDFDULL,
811 0x00000000FDFDFDFDULL,
812 0x0000000000FDFDFDULL,
813 0x000000000000FDFDULL,
814 0x00000000000000FDULL,
815 };
816
817 word screen_triangles[28][32];
818 /*
819 qword triangles[4][16]= //[direction][value]
820 {
821 {
822 0x00000000, 0x10000000, 0x21000000, 0x32100000, 0x43210000, 0x54321000, 0x65432100, 0x76543210, 0x87654321, 0x88765432, 0x88876543, 0x88887654, 0x88888765, 0x88888876, 0x88888887, 0x88888888
823 },
824 {
825 0x00000000, 0xF0000000, 0xEF000000, 0xFDF00000, 0xCFDF0000, 0xBCFDF000, 0xABCFDF00, 0x9ABCFDF0, 0x89ABCFDF, 0x889ABCFD, 0x8889ABCD, 0x88889ABC, 0x888889AB, 0x8888889A, 0x88888889, 0x88888888
826 },
827 {
828 0x00000000, 0x00000001, 0x00000012, 0x00000123, 0x00001234, 0x00012345, 0x00123456, 0x01234567, 0x12345678, 0x23456788, 0x34567888, 0x45678888, 0x56788888, 0x67888888, 0x78888888, 0x88888888
829 },
830 {
831 0x00000000, 0x0000000F, 0x000000FE, 0x00000FED, 0x0000FEDC, 0x000FEDCB, 0x00FEDCBA, 0x0FEDCBA9, 0xFEDCBA98, 0xEDCBA988, 0xDCBA9888, 0xCBA98888, 0xBA988888, 0xA9888888, 0x98888888, 0x88888888
832 }
833 };
834 */
835
836
837 /*
838 byte triangles[4][16][8]= //[direction][value][line]
839 {
840 {
841 {
842 0, 0, 0, 0, 0, 0, 0, 0
843 },
844 {
845 1, 0, 0, 0, 0, 0, 0, 0
846 },
847 {
848 2, 1, 0, 0, 0, 0, 0, 0
849 },
850 {
851 3, 2, 1, 0, 0, 0, 0, 0
852 },
853 {
854 4, 3, 2, 1, 0, 0, 0, 0
855 },
856 {
857 5, 4, 3, 2, 1, 0, 0, 0
858 },
859 {
860 6, 5, 4, 3, 2, 1, 0, 0
861 },
862 {
863 7, 6, 5, 4, 3, 2, 1, 0
864 },
865 {
866 8, 7, 6, 5, 4, 3, 2, 1
867 },
868 {
869 8, 8, 7, 6, 5, 4, 3, 2
870 },
871 {
872 8, 8, 8, 7, 6, 5, 4, 3
873 },
874 {
875 8, 8, 8, 8, 7, 6, 5, 4
876 },
877 {
878 8, 8, 8, 8, 8, 7, 6, 5
879 },
880 {
881 8, 8, 8, 8, 8, 8, 7, 6
882 },
883 {
884 8, 8, 8, 8, 8, 8, 8, 7
885 },
886 {
887 8, 8, 8, 8, 8, 8, 8, 8
888 }
889 },
890 {
891 {
892 0, 0, 0, 0, 0, 0, 0, 0
893 },
894 {
895 15, 0, 0, 0, 0, 0, 0, 0
896 },
897 {
898 14, 15, 0, 0, 0, 0, 0, 0
899 },
900 {
901 13, 14, 15, 0, 0, 0, 0, 0
902 },
903 {
904 12, 13, 14, 15, 0, 0, 0, 0
905 },
906 {
907 11, 12, 13, 14, 15, 0, 0, 0
908 },
909 {
910 10, 11, 12, 13, 14, 15, 0, 0
911 },
912 {
913 9, 10, 11, 12, 13, 14, 15, 0
914 },
915 {
916 8, 9, 10, 11, 12, 13, 14, 15
917 },
918 {
919 8, 8, 9, 10, 11, 12, 13, 14
920 },
921 {
922 8, 8, 8, 9, 10, 11, 12, 13
923 },
924 {
925 8, 8, 8, 8, 9, 10, 11, 12
926 },
927 {
928 8, 8, 8, 8, 8, 9, 10, 11
929 },
930 {
931 8, 8, 8, 8, 8, 8, 9, 10
932 },
933 {
934 8, 8, 8, 8, 8, 8, 8, 9
935 },
936 {
937 8, 8, 8, 8, 8, 8, 8, 8
938 }
939 },
940 {
941 {
942 0, 0, 0, 0, 0, 0, 0, 0
943 },
944 {
945 0, 0, 0, 0, 0, 0, 0, 1
946 },
947 {
948 0, 0, 0, 0, 0, 0, 1, 2
949 },
950 {
951 0, 0, 0, 0, 0, 1, 2, 3
952 },
953 {
954 0, 0, 0, 0, 1, 2, 3, 4
955 },
956 {
957 0, 0, 0, 1, 2, 3, 4, 5
958 },
959 {
960 0, 0, 1, 2, 3, 4, 5, 6
961 },
962 {
963 0, 1, 2, 3, 4, 5, 6, 7
964 },
965 {
966 1, 2, 3, 4, 5, 6, 7, 8
967 },
968 {
969 2, 3, 4, 5, 6, 7, 8, 8
970 },
971 {
972 3, 4, 5, 6, 7, 8, 8, 8
973 },
974 {
975 4, 5, 6, 7, 8, 8, 8, 8
976 },
977 {
978 5, 6, 7, 8, 8, 8, 8, 8
979 },
980 {
981 6, 7, 8, 8, 8, 8, 8, 8
982 },
983 {
984 7, 8, 8, 8, 8, 8, 8, 8
985 },
986 {
987 8, 8, 8, 8, 8, 8, 8, 8
988 }
989 },
990 {
991 {
992 0, 0, 0, 0, 0, 0, 0, 0
993 },
994 {
995 0, 0, 0, 0, 0, 0, 0, 15
996 },
997 {
998 0, 0, 0, 0, 0, 0, 15, 14
999 },
1000 {
1001 0, 0, 0, 0, 0, 15, 14, 13
1002 },
1003 {
1004 0, 0, 0, 0, 15, 14, 13, 12
1005 },
1006 {
1007 0, 0, 0, 15, 14, 13, 12, 11
1008 },
1009 {
1010 0, 0, 15, 14, 13, 12, 11, 10
1011 },
1012 {
1013 0, 15, 14, 13, 12, 11, 10, 9
1014 },
1015 {
1016 15, 14, 13, 12, 11, 10, 9, 8
1017 },
1018 {
1019 14, 13, 12, 11, 10, 9, 8, 8
1020 },
1021 {
1022 13, 12, 11, 10, 9, 8, 8, 8
1023 },
1024 {
1025 12, 11, 10, 9, 8, 8, 8, 8
1026 },
1027 {
1028 11, 10, 9, 8, 8, 8, 8, 8
1029 },
1030 {
1031 10, 9, 8, 8, 8, 8, 8, 8
1032 },
1033 {
1034 9, 8, 8, 8, 8, 8, 8, 8
1035 },
1036 {
1037 8, 8, 8, 8, 8, 8, 8, 8
1038 }
1039 }
1040 };
1041 */
1042
1043
1044
1045 /*
1046 for (int32_t blockrow=0; blockrow<30; ++i)
1047 {
1048 for (int32_t linerow=0; linerow<8; ++i)
1049 {
1050 qword *triangleline=(qword*)(tmp_scr->line[(blockrow*8+linerow)]);
1051 for (int32_t blockcolumn=0; blockcolumn<40; ++i)
1052 {
1053 triangleline=triangles[0][screen_triangles[blockrow][blockcolumn]][linerow];
1054 ++triangleline;
1055 }
1056 }
1057 }
1058 */
1059
1060 // the ULL suffixes are to prevent this warning:
1061 // warning: integer constant is too large for "int32_t" type
1062
1063 qword triangles[4][16][8]= //[direction][value][line]
1064 {
1065 {
1066 {
1067 0x0000000000000000ULL,
1068 0x0000000000000000ULL,
1069 0x0000000000000000ULL,
1070 0x0000000000000000ULL,
1071 0x0000000000000000ULL,
1072 0x0000000000000000ULL,
1073 0x0000000000000000ULL,
1074 0x0000000000000000ULL
1075 },
1076 {
1077 0xFD00000000000000ULL,
1078 0x0000000000000000ULL,
1079 0x0000000000000000ULL,
1080 0x0000000000000000ULL,
1081 0x0000000000000000ULL,
1082 0x0000000000000000ULL,
1083 0x0000000000000000ULL,
1084 0x0000000000000000ULL
1085 },
1086 {
1087 0xFDFD000000000000ULL,
1088 0xFD00000000000000ULL,
1089 0x0000000000000000ULL,
1090 0x0000000000000000ULL,
1091 0x0000000000000000ULL,
1092 0x0000000000000000ULL,
1093 0x0000000000000000ULL,
1094 0x0000000000000000ULL
1095 },
1096 {
1097 0xFDFDFD0000000000ULL,
1098 0xFDFD000000000000ULL,
1099 0xFD00000000000000ULL,
1100 0x0000000000000000ULL,
1101 0x0000000000000000ULL,
1102 0x0000000000000000ULL,
1103 0x0000000000000000ULL,
1104 0x0000000000000000ULL
1105 },
1106 {
1107 0xFDFDFDFD00000000ULL,
1108 0xFDFDFD0000000000ULL,
1109 0xFDFD000000000000ULL,
1110 0xFD00000000000000ULL,
1111 0x0000000000000000ULL,
1112 0x0000000000000000ULL,
1113 0x0000000000000000ULL,
1114 0x0000000000000000ULL
1115 },
1116 {
1117 0xFDFDFDFDFD000000ULL,
1118 0xFDFDFDFD00000000ULL,
1119 0xFDFDFD0000000000ULL,
1120 0xFDFD000000000000ULL,
1121 0xFD00000000000000ULL,
1122 0x0000000000000000ULL,
1123 0x0000000000000000ULL,
1124 0x0000000000000000ULL
1125 },
1126 {
1127 0xFDFDFDFDFDFD0000ULL,
1128 0xFDFDFDFDFD000000ULL,
1129 0xFDFDFDFD00000000ULL,
1130 0xFDFDFD0000000000ULL,
1131 0xFDFD000000000000ULL,
1132 0xFD00000000000000ULL,
1133 0x0000000000000000ULL,
1134 0x0000000000000000ULL
1135 },
1136 {
1137 0xFDFDFDFDFDFDFD00ULL,
1138 0xFDFDFDFDFDFD0000ULL,
1139 0xFDFDFDFDFD000000ULL,
1140 0xFDFDFDFD00000000ULL,
1141 0xFDFDFD0000000000ULL,
1142 0xFDFD000000000000ULL,
1143 0xFD00000000000000ULL,
1144 0x0000000000000000ULL
1145 },
1146 {
1147 0xFDFDFDFDFDFDFDFDULL,
1148 0xFDFDFDFDFDFDFD00ULL,
1149 0xFDFDFDFDFDFD0000ULL,
1150 0xFDFDFDFDFD000000ULL,
1151 0xFDFDFDFD00000000ULL,
1152 0xFDFDFD0000000000ULL,
1153 0xFDFD000000000000ULL,
1154 0xFD00000000000000ULL
1155 },
1156 {
1157 0xFDFDFDFDFDFDFDFDULL,
1158 0xFDFDFDFDFDFDFDFDULL,
1159 0xFDFDFDFDFDFDFD00ULL,
1160 0xFDFDFDFDFDFD0000ULL,
1161 0xFDFDFDFDFD000000ULL,
1162 0xFDFDFDFD00000000ULL,
1163 0xFDFDFD0000000000ULL,
1164 0xFDFD000000000000ULL
1165 },
1166 {
1167 0xFDFDFDFDFDFDFDFDULL,
1168 0xFDFDFDFDFDFDFDFDULL,
1169 0xFDFDFDFDFDFDFDFDULL,
1170 0xFDFDFDFDFDFDFD00ULL,
1171 0xFDFDFDFDFDFD0000ULL,
1172 0xFDFDFDFDFD000000ULL,
1173 0xFDFDFDFD00000000ULL,
1174 0xFDFDFD0000000000ULL
1175 },
1176 {
1177 0xFDFDFDFDFDFDFDFDULL,
1178 0xFDFDFDFDFDFDFDFDULL,
1179 0xFDFDFDFDFDFDFDFDULL,
1180 0xFDFDFDFDFDFDFDFDULL,
1181 0xFDFDFDFDFDFDFD00ULL,
1182 0xFDFDFDFDFDFD0000ULL,
1183 0xFDFDFDFDFD000000ULL,
1184 0xFDFDFDFD00000000ULL
1185 },
1186 {
1187 0xFDFDFDFDFDFDFDFDULL,
1188 0xFDFDFDFDFDFDFDFDULL,
1189 0xFDFDFDFDFDFDFDFDULL,
1190 0xFDFDFDFDFDFDFDFDULL,
1191 0xFDFDFDFDFDFDFDFDULL,
1192 0xFDFDFDFDFDFDFD00ULL,
1193 0xFDFDFDFDFDFD0000ULL,
1194 0xFDFDFDFDFD000000ULL
1195 },
1196 {
1197 0xFDFDFDFDFDFDFDFDULL,
1198 0xFDFDFDFDFDFDFDFDULL,
1199 0xFDFDFDFDFDFDFDFDULL,
1200 0xFDFDFDFDFDFDFDFDULL,
1201 0xFDFDFDFDFDFDFDFDULL,
1202 0xFDFDFDFDFDFDFDFDULL,
1203 0xFDFDFDFDFDFDFD00ULL,
1204 0xFDFDFDFDFDFD0000ULL
1205 },
1206 {
1207 0xFDFDFDFDFDFDFDFDULL,
1208 0xFDFDFDFDFDFDFDFDULL,
1209 0xFDFDFDFDFDFDFDFDULL,
1210 0xFDFDFDFDFDFDFDFDULL,
1211 0xFDFDFDFDFDFDFDFDULL,
1212 0xFDFDFDFDFDFDFDFDULL,
1213 0xFDFDFDFDFDFDFDFDULL,
1214 0xFDFDFDFDFDFDFD00ULL
1215 },
1216 {
1217 0xFDFDFDFDFDFDFDFDULL,
1218 0xFDFDFDFDFDFDFDFDULL,
1219 0xFDFDFDFDFDFDFDFDULL,
1220 0xFDFDFDFDFDFDFDFDULL,
1221 0xFDFDFDFDFDFDFDFDULL,
1222 0xFDFDFDFDFDFDFDFDULL,
1223 0xFDFDFDFDFDFDFDFDULL,
1224 0xFDFDFDFDFDFDFDFDULL
1225 }
1226 },
1227 {
1228 {
1229 0x0000000000000000ULL,
1230 0x0000000000000000ULL,
1231 0x0000000000000000ULL,
1232 0x0000000000000000ULL,
1233 0x0000000000000000ULL,
1234 0x0000000000000000ULL,
1235 0x0000000000000000ULL,
1236 0x0000000000000000ULL
1237 },
1238 {
1239 0x00000000000000FDULL,
1240 0x0000000000000000ULL,
1241 0x0000000000000000ULL,
1242 0x0000000000000000ULL,
1243 0x0000000000000000ULL,
1244 0x0000000000000000ULL,
1245 0x0000000000000000ULL,
1246 0x0000000000000000ULL
1247 },
1248 {
1249 0x000000000000FDFDULL,
1250 0x00000000000000FDULL,
1251 0x0000000000000000ULL,
1252 0x0000000000000000ULL,
1253 0x0000000000000000ULL,
1254 0x0000000000000000ULL,
1255 0x0000000000000000ULL,
1256 0x0000000000000000ULL
1257 },
1258 {
1259 0x0000000000FDFDFDULL,
1260 0x000000000000FDFDULL,
1261 0x00000000000000FDULL,
1262 0x0000000000000000ULL,
1263 0x0000000000000000ULL,
1264 0x0000000000000000ULL,
1265 0x0000000000000000ULL,
1266 0x0000000000000000ULL
1267 },
1268 {
1269 0x00000000FDFDFDFDULL,
1270 0x0000000000FDFDFDULL,
1271 0x000000000000FDFDULL,
1272 0x00000000000000FDULL,
1273 0x0000000000000000ULL,
1274 0x0000000000000000ULL,
1275 0x0000000000000000ULL,
1276 0x0000000000000000ULL
1277 },
1278 {
1279 0x000000FDFDFDFDFDULL,
1280 0x00000000FDFDFDFDULL,
1281 0x0000000000FDFDFDULL,
1282 0x000000000000FDFDULL,
1283 0x00000000000000FDULL,
1284 0x0000000000000000ULL,
1285 0x0000000000000000ULL,
1286 0x0000000000000000ULL
1287 },
1288 {
1289 0x0000FDFDFDFDFDFDULL,
1290 0x000000FDFDFDFDFDULL,
1291 0x00000000FDFDFDFDULL,
1292 0x0000000000FDFDFDULL,
1293 0x000000000000FDFDULL,
1294 0x00000000000000FDULL,
1295 0x0000000000000000ULL,
1296 0x0000000000000000ULL
1297 },
1298 {
1299 0x00FDFDFDFDFDFDFDULL,
1300 0x0000FDFDFDFDFDFDULL,
1301 0x000000FDFDFDFDFDULL,
1302 0x00000000FDFDFDFDULL,
1303 0x0000000000FDFDFDULL,
1304 0x000000000000FDFDULL,
1305 0x00000000000000FDULL,
1306 0x0000000000000000ULL
1307 },
1308 {
1309 0xFDFDFDFDFDFDFDFDULL,
1310 0x00FDFDFDFDFDFDFDULL,
1311 0x0000FDFDFDFDFDFDULL,
1312 0x000000FDFDFDFDFDULL,
1313 0x00000000FDFDFDFDULL,
1314 0x0000000000FDFDFDULL,
1315 0x000000000000FDFDULL,
1316 0x00000000000000FDULL
1317 },
1318 {
1319 0xFDFDFDFDFDFDFDFDULL,
1320 0xFDFDFDFDFDFDFDFDULL,
1321 0x00FDFDFDFDFDFDFDULL,
1322 0x0000FDFDFDFDFDFDULL,
1323 0x000000FDFDFDFDFDULL,
1324 0x00000000FDFDFDFDULL,
1325 0x0000000000FDFDFDULL,
1326 0x000000000000FDFDULL
1327 },
1328 {
1329 0xFDFDFDFDFDFDFDFDULL,
1330 0xFDFDFDFDFDFDFDFDULL,
1331 0xFDFDFDFDFDFDFDFDULL,
1332 0x00FDFDFDFDFDFDFDULL,
1333 0x0000FDFDFDFDFDFDULL,
1334 0x000000FDFDFDFDFDULL,
1335 0x00000000FDFDFDFDULL,
1336 0x0000000000FDFDFDULL
1337 },
1338 {
1339 0xFDFDFDFDFDFDFDFDULL,
1340 0xFDFDFDFDFDFDFDFDULL,
1341 0xFDFDFDFDFDFDFDFDULL,
1342 0xFDFDFDFDFDFDFDFDULL,
1343 0x00FDFDFDFDFDFDFDULL,
1344 0x0000FDFDFDFDFDFDULL,
1345 0x000000FDFDFDFDFDULL,
1346 0x00000000FDFDFDFDULL
1347 },
1348 {
1349 0xFDFDFDFDFDFDFDFDULL,
1350 0xFDFDFDFDFDFDFDFDULL,
1351 0xFDFDFDFDFDFDFDFDULL,
1352 0xFDFDFDFDFDFDFDFDULL,
1353 0xFDFDFDFDFDFDFDFDULL,
1354 0x00FDFDFDFDFDFDFDULL,
1355 0x0000FDFDFDFDFDFDULL,
1356 0x000000FDFDFDFDFDULL
1357 },
1358 {
1359 0xFDFDFDFDFDFDFDFDULL,
1360 0xFDFDFDFDFDFDFDFDULL,
1361 0xFDFDFDFDFDFDFDFDULL,
1362 0xFDFDFDFDFDFDFDFDULL,
1363 0xFDFDFDFDFDFDFDFDULL,
1364 0xFDFDFDFDFDFDFDFDULL,
1365 0x00FDFDFDFDFDFDFDULL,
1366 0x0000FDFDFDFDFDFDULL
1367 },
1368 {
1369 0xFDFDFDFDFDFDFDFDULL,
1370 0xFDFDFDFDFDFDFDFDULL,
1371 0xFDFDFDFDFDFDFDFDULL,
1372 0xFDFDFDFDFDFDFDFDULL,
1373 0xFDFDFDFDFDFDFDFDULL,
1374 0xFDFDFDFDFDFDFDFDULL,
1375 0xFDFDFDFDFDFDFDFDULL,
1376 0x00FDFDFDFDFDFDFDULL
1377 },
1378 {
1379 0xFDFDFDFDFDFDFDFDULL,
1380 0xFDFDFDFDFDFDFDFDULL,
1381 0xFDFDFDFDFDFDFDFDULL,
1382 0xFDFDFDFDFDFDFDFDULL,
1383 0xFDFDFDFDFDFDFDFDULL,
1384 0xFDFDFDFDFDFDFDFDULL,
1385 0xFDFDFDFDFDFDFDFDULL,
1386 0xFDFDFDFDFDFDFDFDULL
1387 }
1388 },
1389 {
1390 {
1391 0x0000000000000000ULL,
1392 0x0000000000000000ULL,
1393 0x0000000000000000ULL,
1394 0x0000000000000000ULL,
1395 0x0000000000000000ULL,
1396 0x0000000000000000ULL,
1397 0x0000000000000000ULL,
1398 0x0000000000000000ULL
1399 },
1400 {
1401 0x0000000000000000ULL,
1402 0x0000000000000000ULL,
1403 0x0000000000000000ULL,
1404 0x0000000000000000ULL,
1405 0x0000000000000000ULL,
1406 0x0000000000000000ULL,
1407 0x0000000000000000ULL,
1408 0xFD00000000000000ULL
1409 },
1410 {
1411 0x0000000000000000ULL,
1412 0x0000000000000000ULL,
1413 0x0000000000000000ULL,
1414 0x0000000000000000ULL,
1415 0x0000000000000000ULL,
1416 0x0000000000000000ULL,
1417 0xFD00000000000000ULL,
1418 0xFDFD000000000000ULL
1419 },
1420 {
1421 0x0000000000000000ULL,
1422 0x0000000000000000ULL,
1423 0x0000000000000000ULL,
1424 0x0000000000000000ULL,
1425 0x0000000000000000ULL,
1426 0xFD00000000000000ULL,
1427 0xFDFD000000000000ULL,
1428 0xFDFDFD0000000000ULL
1429 },
1430 {
1431 0x0000000000000000ULL,
1432 0x0000000000000000ULL,
1433 0x0000000000000000ULL,
1434 0x0000000000000000ULL,
1435 0xFD00000000000000ULL,
1436 0xFDFD000000000000ULL,
1437 0xFDFDFD0000000000ULL,
1438 0xFDFDFDFD00000000ULL
1439 },
1440 {
1441 0x0000000000000000ULL,
1442 0x0000000000000000ULL,
1443 0x0000000000000000ULL,
1444 0xFD00000000000000ULL,
1445 0xFDFD000000000000ULL,
1446 0xFDFDFD0000000000ULL,
1447 0xFDFDFDFD00000000ULL,
1448 0xFDFDFDFDFD000000ULL
1449 },
1450 {
1451 0x0000000000000000ULL,
1452 0x0000000000000000ULL,
1453 0xFD00000000000000ULL,
1454 0xFDFD000000000000ULL,
1455 0xFDFDFD0000000000ULL,
1456 0xFDFDFDFD00000000ULL,
1457 0xFDFDFDFDFD000000ULL,
1458 0xFDFDFDFDFDFD0000ULL
1459 },
1460 {
1461 0x0000000000000000ULL,
1462 0xFD00000000000000ULL,
1463 0xFDFD000000000000ULL,
1464 0xFDFDFD0000000000ULL,
1465 0xFDFDFDFD00000000ULL,
1466 0xFDFDFDFDFD000000ULL,
1467 0xFDFDFDFDFDFD0000ULL,
1468 0xFDFDFDFDFDFDFD00ULL
1469 },
1470 {
1471 0xFD00000000000000ULL,
1472 0xFDFD000000000000ULL,
1473 0xFDFDFD0000000000ULL,
1474 0xFDFDFDFD00000000ULL,
1475 0xFDFDFDFDFD000000ULL,
1476 0xFDFDFDFDFDFD0000ULL,
1477 0xFDFDFDFDFDFDFD00ULL,
1478 0xFDFDFDFDFDFDFDFDULL
1479 },
1480 {
1481 0xFDFD000000000000ULL,
1482 0xFDFDFD0000000000ULL,
1483 0xFDFDFDFD00000000ULL,
1484 0xFDFDFDFDFD000000ULL,
1485 0xFDFDFDFDFDFD0000ULL,
1486 0xFDFDFDFDFDFDFD00ULL,
1487 0xFDFDFDFDFDFDFDFDULL,
1488 0xFDFDFDFDFDFDFDFDULL
1489 },
1490 {
1491 0xFDFDFD0000000000ULL,
1492 0xFDFDFDFD00000000ULL,
1493 0xFDFDFDFDFD000000ULL,
1494 0xFDFDFDFDFDFD0000ULL,
1495 0xFDFDFDFDFDFDFD00ULL,
1496 0xFDFDFDFDFDFDFDFDULL,
1497 0xFDFDFDFDFDFDFDFDULL,
1498 0xFDFDFDFDFDFDFDFDULL
1499 },
1500 {
1501 0xFDFDFDFD00000000ULL,
1502 0xFDFDFDFDFD000000ULL,
1503 0xFDFDFDFDFDFD0000ULL,
1504 0xFDFDFDFDFDFDFD00ULL,
1505 0xFDFDFDFDFDFDFDFDULL,
1506 0xFDFDFDFDFDFDFDFDULL,
1507 0xFDFDFDFDFDFDFDFDULL,
1508 0xFDFDFDFDFDFDFDFDULL
1509 },
1510 {
1511 0xFDFDFDFDFD000000ULL,
1512 0xFDFDFDFDFDFD0000ULL,
1513 0xFDFDFDFDFDFDFD00ULL,
1514 0xFDFDFDFDFDFDFDFDULL,
1515 0xFDFDFDFDFDFDFDFDULL,
1516 0xFDFDFDFDFDFDFDFDULL,
1517 0xFDFDFDFDFDFDFDFDULL,
1518 0xFDFDFDFDFDFDFDFDULL
1519 },
1520 {
1521 0xFDFDFDFDFDFD0000ULL,
1522 0xFDFDFDFDFDFDFD00ULL,
1523 0xFDFDFDFDFDFDFDFDULL,
1524 0xFDFDFDFDFDFDFDFDULL,
1525 0xFDFDFDFDFDFDFDFDULL,
1526 0xFDFDFDFDFDFDFDFDULL,
1527 0xFDFDFDFDFDFDFDFDULL,
1528 0xFDFDFDFDFDFDFDFDULL
1529 },
1530 {
1531 0xFDFDFDFDFDFDFD00ULL,
1532 0xFDFDFDFDFDFDFDFDULL,
1533 0xFDFDFDFDFDFDFDFDULL,
1534 0xFDFDFDFDFDFDFDFDULL,
1535 0xFDFDFDFDFDFDFDFDULL,
1536 0xFDFDFDFDFDFDFDFDULL,
1537 0xFDFDFDFDFDFDFDFDULL,
1538 0xFDFDFDFDFDFDFDFDULL
1539 },
1540 {
1541 0xFDFDFDFDFDFDFDFDULL,
1542 0xFDFDFDFDFDFDFDFDULL,
1543 0xFDFDFDFDFDFDFDFDULL,
1544 0xFDFDFDFDFDFDFDFDULL,
1545 0xFDFDFDFDFDFDFDFDULL,
1546 0xFDFDFDFDFDFDFDFDULL,
1547 0xFDFDFDFDFDFDFDFDULL,
1548 0xFDFDFDFDFDFDFDFDULL
1549 }
1550 },
1551 {
1552 {
1553 0x0000000000000000ULL,
1554 0x0000000000000000ULL,
1555 0x0000000000000000ULL,
1556 0x0000000000000000ULL,
1557 0x0000000000000000ULL,
1558 0x0000000000000000ULL,
1559 0x0000000000000000ULL,
1560 0x0000000000000000ULL
1561 },
1562 {
1563 0x0000000000000000ULL,
1564 0x0000000000000000ULL,
1565 0x0000000000000000ULL,
1566 0x0000000000000000ULL,
1567 0x0000000000000000ULL,
1568 0x0000000000000000ULL,
1569 0x0000000000000000ULL,
1570 0x00000000000000FDULL
1571 },
1572 {
1573 0x0000000000000000ULL,
1574 0x0000000000000000ULL,
1575 0x0000000000000000ULL,
1576 0x0000000000000000ULL,
1577 0x0000000000000000ULL,
1578 0x0000000000000000ULL,
1579 0x00000000000000FDULL,
1580 0x000000000000FDFDULL
1581 },
1582 {
1583 0x0000000000000000ULL,
1584 0x0000000000000000ULL,
1585 0x0000000000000000ULL,
1586 0x0000000000000000ULL,
1587 0x0000000000000000ULL,
1588 0x00000000000000FDULL,
1589 0x000000000000FDFDULL,
1590 0x0000000000FDFDFDULL
1591 },
1592 {
1593 0x0000000000000000ULL,
1594 0x0000000000000000ULL,
1595 0x0000000000000000ULL,
1596 0x0000000000000000ULL,
1597 0x00000000000000FDULL,
1598 0x000000000000FDFDULL,
1599 0x0000000000FDFDFDULL,
1600 0x00000000FDFDFDFDULL
1601 },
1602 {
1603 0x0000000000000000ULL,
1604 0x0000000000000000ULL,
1605 0x0000000000000000ULL,
1606 0x00000000000000FDULL,
1607 0x000000000000FDFDULL,
1608 0x0000000000FDFDFDULL,
1609 0x00000000FDFDFDFDULL,
1610 0x000000FDFDFDFDFDULL
1611 },
1612 {
1613 0x0000000000000000ULL,
1614 0x0000000000000000ULL,
1615 0x00000000000000FDULL,
1616 0x000000000000FDFDULL,
1617 0x0000000000FDFDFDULL,
1618 0x00000000FDFDFDFDULL,
1619 0x000000FDFDFDFDFDULL,
1620 0x0000FDFDFDFDFDFDULL
1621 },
1622 {
1623 0x0000000000000000ULL,
1624 0x00000000000000FDULL,
1625 0x000000000000FDFDULL,
1626 0x0000000000FDFDFDULL,
1627 0x00000000FDFDFDFDULL,
1628 0x000000FDFDFDFDFDULL,
1629 0x0000FDFDFDFDFDFDULL,
1630 0x00FDFDFDFDFDFDFDULL
1631 },
1632 {
1633 0x00000000000000FDULL,
1634 0x000000000000FDFDULL,
1635 0x0000000000FDFDFDULL,
1636 0x00000000FDFDFDFDULL,
1637 0x000000FDFDFDFDFDULL,
1638 0x0000FDFDFDFDFDFDULL,
1639 0x00FDFDFDFDFDFDFDULL,
1640 0xFDFDFDFDFDFDFDFDULL
1641 },
1642 {
1643 0x000000000000FDFDULL,
1644 0x0000000000FDFDFDULL,
1645 0x00000000FDFDFDFDULL,
1646 0x000000FDFDFDFDFDULL,
1647 0x0000FDFDFDFDFDFDULL,
1648 0x00FDFDFDFDFDFDFDULL,
1649 0xFDFDFDFDFDFDFDFDULL,
1650 0xFDFDFDFDFDFDFDFDULL
1651 },
1652 {
1653 0x0000000000FDFDFDULL,
1654 0x00000000FDFDFDFDULL,
1655 0x000000FDFDFDFDFDULL,
1656 0x0000FDFDFDFDFDFDULL,
1657 0x00FDFDFDFDFDFDFDULL,
1658 0xFDFDFDFDFDFDFDFDULL,
1659 0xFDFDFDFDFDFDFDFDULL,
1660 0xFDFDFDFDFDFDFDFDULL
1661 },
1662 {
1663 0x00000000FDFDFDFDULL,
1664 0x000000FDFDFDFDFDULL,
1665 0x0000FDFDFDFDFDFDULL,
1666 0x00FDFDFDFDFDFDFDULL,
1667 0xFDFDFDFDFDFDFDFDULL,
1668 0xFDFDFDFDFDFDFDFDULL,
1669 0xFDFDFDFDFDFDFDFDULL,
1670 0xFDFDFDFDFDFDFDFDULL
1671 },
1672 {
1673 0x000000FDFDFDFDFDULL,
1674 0x0000FDFDFDFDFDFDULL,
1675 0x00FDFDFDFDFDFDFDULL,
1676 0xFDFDFDFDFDFDFDFDULL,
1677 0xFDFDFDFDFDFDFDFDULL,
1678 0xFDFDFDFDFDFDFDFDULL,
1679 0xFDFDFDFDFDFDFDFDULL,
1680 0xFDFDFDFDFDFDFDFDULL
1681 },
1682 {
1683 0x0000FDFDFDFDFDFDULL,
1684 0x00FDFDFDFDFDFDFDULL,
1685 0xFDFDFDFDFDFDFDFDULL,
1686 0xFDFDFDFDFDFDFDFDULL,
1687 0xFDFDFDFDFDFDFDFDULL,
1688 0xFDFDFDFDFDFDFDFDULL,
1689 0xFDFDFDFDFDFDFDFDULL,
1690 0xFDFDFDFDFDFDFDFDULL
1691 },
1692 {
1693 0x00FDFDFDFDFDFDFDULL,
1694 0xFDFDFDFDFDFDFDFDULL,
1695 0xFDFDFDFDFDFDFDFDULL,
1696 0xFDFDFDFDFDFDFDFDULL,
1697 0xFDFDFDFDFDFDFDFDULL,
1698 0xFDFDFDFDFDFDFDFDULL,
1699 0xFDFDFDFDFDFDFDFDULL,
1700 0xFDFDFDFDFDFDFDFDULL
1701 },
1702 {
1703 0xFDFDFDFDFDFDFDFDULL,
1704 0xFDFDFDFDFDFDFDFDULL,
1705 0xFDFDFDFDFDFDFDFDULL,
1706 0xFDFDFDFDFDFDFDFDULL,
1707 0xFDFDFDFDFDFDFDFDULL,
1708 0xFDFDFDFDFDFDFDFDULL,
1709 0xFDFDFDFDFDFDFDFDULL,
1710 0xFDFDFDFDFDFDFDFDULL
1711 }
1712 }
1713 };
1714
1715 int32_t black_opening_count=0;
1716 int32_t black_opening_x,black_opening_y;
1717 int32_t black_opening_shape;
1718
1719 791 int32_t choose_opening_shape()
1720 {
1721 // First, count how many bits are set
1722 791 int32_t numBits=0;
1723 int32_t bitCounter;
1724
1725
2/2
✓ Branch 0 taken 3955 times.
✓ Branch 1 taken 791 times.
4746 for(int32_t i=0; i<bosMAX; i++)
1726 {
1727
2/2
✓ Branch 0 taken 2948 times.
✓ Branch 1 taken 1007 times.
3955 if(COOLSCROLL&(1<<i))
1728 1007 numBits++;
1729 3955 }
1730
1731 // Shouldn't happen...
1732
1/2
✓ Branch 0 taken 791 times.
✗ Branch 1 not taken.
791 if(numBits==0)
1733 return bosCIRCLE;
1734
1735 // Pick a bit
1736 791 bitCounter=zc_rand()%numBits+1;
1737
1738
2/2
✓ Branch 0 taken 1003 times.
✓ Branch 1 taken 26 times.
1029 for(int32_t i=0; i<bosMAX; i++)
1739 {
1740 // If this bit is set, decrement the bit counter
1741
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 921 times.
1003 if(COOLSCROLL&(1<<i))
1742 921 bitCounter--;
1743
1744 // When the counter hits 0, return a value based on
1745 // which bit it stopped on.
1746 // Reminder: enum {bosCIRCLE=0, bosOVAL, bosTRIANGLE, bosSMAS, bosFADEBLACK, bosMAX};
1747
2/2
✓ Branch 0 taken 765 times.
✓ Branch 1 taken 238 times.
1003 if(bitCounter==0)
1748 765 return i;
1749 238 }
1750
1751 // Shouldn't be necessary, but the compiler might complain, at least
1752 26 return bosCIRCLE;
1753 791 }
1754
1755 216 void close_black_opening(int32_t x, int32_t y, bool wait, int32_t shape)
1756 {
1757
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 216 times.
216 black_opening_shape= (shape>-1 ? shape : choose_opening_shape());
1758
1759 216 int32_t w=256, h=224;
1760 216 int32_t blockrows=28, blockcolumns=32;
1761 216 int32_t xoffset=(x-(w/2))/8, yoffset=(y-(h/2))/8;
1762
1763
2/2
✓ Branch 0 taken 6048 times.
✓ Branch 1 taken 216 times.
6264 for(int32_t blockrow=0; blockrow<blockrows; ++blockrow) //30
1764 {
1765
2/2
✓ Branch 0 taken 193536 times.
✓ Branch 1 taken 6048 times.
199584 for(int32_t blockcolumn=0; blockcolumn<blockcolumns; ++blockcolumn) //40
1766 {
1767
2/2
✓ Branch 0 taken 103944 times.
✓ Branch 1 taken 89592 times.
193536 screen_triangles[blockrow][blockcolumn]=zc_max(abs(int32_t(double(blockcolumns-1)/2-blockcolumn+xoffset)),abs(int32_t(double(blockrows-1)/2-blockrow+yoffset)))|0x0100|((blockrow-yoffset<blockrows/2)?0:0x8000)|((blockcolumn-xoffset<blockcolumns/2)?0x4000:0);
1768 193536 }
1769 6048 }
1770
1771 216 black_opening_count = 66;
1772 216 black_opening_x = x;
1773 216 black_opening_y = y;
1774 216 lensclk = 0;
1775 //black_opening_shape=(black_opening_shape+1)%bosMAX;
1776
1777
1778
1/2
✓ Branch 0 taken 216 times.
✗ Branch 1 not taken.
216 if(black_opening_shape == bosFADEBLACK)
1779 {
1780 refreshTints();
1781 memcpy(tempblackpal, RAMpal, sizeof(RAMpal)); //Store palette in temp palette for fade effect
1782 }
1783
1/2
✓ Branch 0 taken 216 times.
✗ Branch 1 not taken.
216 if(wait)
1784 {
1785 FFCore.warpScriptCheck();
1786 for(int32_t i=0; i<66; i++)
1787 {
1788 draw_screen(tmpscr);
1789 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
1790 advanceframe(true);
1791
1792 if(Quit)
1793 {
1794 break;
1795 }
1796 }
1797 }
1798 216 }
1799
1800 575 void open_black_opening(int32_t x, int32_t y, bool wait, int32_t shape)
1801 {
1802
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 575 times.
575 black_opening_shape= (shape>-1 ? shape : choose_opening_shape());
1803
1804 575 int32_t w=256, h=224;
1805 575 int32_t blockrows=28, blockcolumns=32;
1806 575 int32_t xoffset=(x-(w/2))/8, yoffset=(y-(h/2))/8;
1807
1808
2/2
✓ Branch 0 taken 16100 times.
✓ Branch 1 taken 575 times.
16675 for(int32_t blockrow=0; blockrow<blockrows; ++blockrow) //30
1809 {
1810
2/2
✓ Branch 0 taken 515200 times.
✓ Branch 1 taken 16100 times.
531300 for(int32_t blockcolumn=0; blockcolumn<blockcolumns; ++blockcolumn) //40
1811 {
1812
2/2
✓ Branch 0 taken 241603 times.
✓ Branch 1 taken 273597 times.
515200 screen_triangles[blockrow][blockcolumn]=zc_max(abs(int32_t(double(blockcolumns-1)/2-blockcolumn+xoffset)),abs(int32_t(double(blockrows-1)/2-blockrow+yoffset)))|0x0100|((blockrow-yoffset<blockrows/2)?0:0x8000)|((blockcolumn-xoffset<blockcolumns/2)?0x4000:0);
1813 515200 }
1814 16100 }
1815
1816 575 black_opening_count = -66;
1817 575 black_opening_x = x;
1818 575 black_opening_y = y;
1819 575 lensclk = 0;
1820
1/2
✓ Branch 0 taken 575 times.
✗ Branch 1 not taken.
575 if(black_opening_shape == bosFADEBLACK)
1821 {
1822 refreshTints();
1823 memcpy(tempblackpal, RAMpal, sizeof(RAMpal)); //Store palette in temp palette for fade effect
1824 }
1825
2/2
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 465 times.
575 if(wait)
1826 {
1827 465 FFCore.warpScriptCheck();
1828
2/2
✓ Branch 0 taken 465 times.
✓ Branch 1 taken 30690 times.
31155 for(int32_t i=0; i<66; i++)
1829 {
1830 30690 draw_screen(tmpscr);
1831 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
1832 30690 advanceframe(true);
1833
1834
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30690 times.
30690 if(Quit)
1835 {
1836 break;
1837 }
1838 30690 }
1839 465 }
1840 575 }
1841
1842 52206 void black_opening(BITMAP *dest,int32_t x,int32_t y,int32_t a,int32_t max_a)
1843 {
1844 52206 clear_to_color(tmp_scr,BLACK);
1845 52206 int32_t w=256, h=224;
1846
1847
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 858 times.
✓ Branch 2 taken 660 times.
✓ Branch 3 taken 1650 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 49038 times.
52206 switch(black_opening_shape)
1848 {
1849 case bosOVAL:
1850 {
1851 858 double new_w=(w/2)+abs(w/2-x);
1852 858 double new_h=(h/2)+abs(h/2-y);
1853 858 double b=sqrt(((new_w*new_w)/4)+(new_h*new_h));
1854 858 ellipsefill(tmp_scr,x,y,int32_t(2*a*b/max_a)/8*8,int32_t(a*b/max_a)/8*8,0);
1855 858 break;
1856 }
1857
1858 case bosTRIANGLE:
1859 {
1860 660 double new_w=(w/2)+abs(w/2-x);
1861 660 double new_h=(h/2)+abs(h/2-y);
1862 660 double r=a*(new_w*sqrt((double)3)+new_h)/max_a;
1863 660 double P2= (PI/2);
1864 660 double P23=(2*PI/3);
1865 660 double P43=(4*PI/3);
1866 660 double Pa= (-4*PI*a/(3*max_a));
1867 660 double angle=P2+Pa;
1868 660 double a0=angle;
1869 660 double a2=angle+P23;
1870 660 double a4=angle+P43;
1871 1320 triangle(tmp_scr, x+int32_t(zc::math::Cos(a0)*r), y-int32_t(zc::math::Sin(a0)*r),
1872 660 x+int32_t(zc::math::Cos(a2)*r), y-int32_t(zc::math::Sin(a2)*r),
1873 660 x+int32_t(zc::math::Cos(a4)*r), y-int32_t(zc::math::Sin(a4)*r),
1874 0);
1875 660 break;
1876 }
1877
1878 case bosSMAS:
1879 {
1880
2/2
✓ Branch 0 taken 660 times.
✓ Branch 1 taken 990 times.
1650 int32_t distance=zc_max(abs(w/2-x),abs(h/2-y))/8;
1881
1882
2/2
✓ Branch 0 taken 46200 times.
✓ Branch 1 taken 1650 times.
47850 for(int32_t blockrow=0; blockrow<28; ++blockrow) //30
1883 {
1884
2/2
✓ Branch 0 taken 369600 times.
✓ Branch 1 taken 46200 times.
415800 for(int32_t linerow=0; linerow<8; ++linerow)
1885 {
1886 369600 qword *triangleline=(qword*)(tmp_scr->line[(blockrow*8+linerow)]);
1887
1888
2/2
✓ Branch 0 taken 11827200 times.
✓ Branch 1 taken 369600 times.
12196800 for(int32_t blockcolumn=0; blockcolumn<32; ++blockcolumn) //40
1889 {
1890 35481600 *triangleline=triangles[(screen_triangles[blockrow][blockcolumn]&0xC000)>>14]
1891
6/6
✓ Branch 0 taken 8249728 times.
✓ Branch 1 taken 3577472 times.
✓ Branch 2 taken 7829672 times.
✓ Branch 3 taken 3997528 times.
✓ Branch 4 taken 4252200 times.
✓ Branch 5 taken 3577472 times.
11827200 [zc_min(zc_max((((31+distance)*(max_a-a)/max_a)+((screen_triangles[blockrow][blockcolumn]&0x0FFF)-0x0100)-(15+distance)),0),15)]
1892 11827200 [linerow];
1893 11827200 ++triangleline;
1894
1895
2/2
✓ Branch 0 taken 10348800 times.
✓ Branch 1 taken 1478400 times.
11827200 if(linerow==0)
1896 {
1897 1478400 }
1898 11827200 }
1899 369600 }
1900 46200 }
1901
1902 1650 break;
1903 }
1904
1905 case bosFADEBLACK:
1906 {
1907 if(black_opening_count<0)
1908 {
1909 black_fade(zc_min(-black_opening_count,63));
1910 }
1911 else if(black_opening_count>0)
1912 {
1913 black_fade(63-zc_max(black_opening_count-3,0));
1914 }
1915 else black_fade(0);
1916 return; //no blitting from tmp_scr!
1917 }
1918
1919 49038 case bosCIRCLE:
1920 default:
1921 {
1922 49038 double new_w=(w/2)+abs(w/2-x);
1923 49038 double new_h=(h/2)+abs(h/2-y);
1924 49038 int32_t r=int32_t(sqrt((new_w*new_w)+(new_h*new_h))*a/max_a);
1925 //circlefill(tmp_scr,x,y,a<<3,0);
1926 49038 circlefill(tmp_scr,x,y,r,0);
1927 49038 break;
1928 }
1929 }
1930
1931 52206 masked_blit(tmp_scr,dest,0,0,0,0,320,240);
1932 52206 }
1933
1934
1935 void black_fade(int32_t fadeamnt)
1936 {
1937 for(int32_t i=0; i < 0xEF; i++)
1938 {
1939 RAMpal[i].r = vbound(tempblackpal[i].r-fadeamnt,0,63);
1940 RAMpal[i].g = vbound(tempblackpal[i].g-fadeamnt,0,63);
1941 RAMpal[i].b = vbound(tempblackpal[i].b-fadeamnt,0,63);
1942 }
1943
1944 refreshpal = true;
1945 }
1946
1947 //----------------------------------------------------------------
1948
1949 15952490 bool item_disabled(int32_t item) //is this item disabled?
1950 {
1951
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15952490 times.
15952490 return (item>=0 && game->items_off[item] != 0);
1952 }
1953
1954 5426600 bool can_use_item(int32_t item_type, int32_t item) //can Hero use this item?
1955 {
1956
2/2
✓ Branch 0 taken 57842 times.
✓ Branch 1 taken 5368758 times.
5426600 if(current_item(item_type, true) >=item)
1957 {
1958 57842 return true;
1959 }
1960
1961 5368758 return false;
1962 5426600 }
1963
1964 22449319 bool has_item(int32_t item_type, int32_t it) //does Hero possess this item?
1965 {
1966
5/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 4086346 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2439977 times.
✓ Branch 6 taken 12012783 times.
✓ Branch 7 taken 3882589 times.
✓ Branch 8 taken 27624 times.
22449319 switch(item_type)
1967 {
1968 case itype_bomb:
1969 case itype_sbomb:
1970 {
1971 int32_t itemid = getItemID(itemsbuf, item_type, it);
1972
1973 if(itemid == -1)
1974 return false;
1975
1976 return (game->get_item(itemid));
1977 }
1978
1979 case itype_clock:
1980 {
1981 4086346 int32_t itemid = getItemID(itemsbuf, item_type, it);
1982
1983
2/4
✓ Branch 0 taken 4086346 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4086346 times.
✗ Branch 3 not taken.
4086346 if(itemid != -1 && (itemsbuf[itemid].flags & ITEM_FLAG1)) //Active clock
1984 return (game->get_item(itemid));
1985 4086346 return Hero.getClock()?1:0;
1986 }
1987
1988 case itype_key:
1989 return (game->get_keys()>0);
1990
1991 case itype_magiccontainer:
1992 return (game->get_maxmagic()>=game->get_mp_per_block());
1993
1994 case itype_triforcepiece: //it: -2=any, -1=current level, other=that level
1995 {
1996
1/3
✓ Branch 0 taken 2439977 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
2439977 switch(it)
1997 {
1998 case -2:
1999 {
2000 for(int32_t i=0; i<MAXLEVELS; i++)
2001 {
2002 if(game->lvlitems[i]&liTRIFORCE)
2003 {
2004 return true;
2005 }
2006 }
2007
2008 return false;
2009 }
2010
2011 case -1:
2012 return (game->lvlitems[dlevel]&liTRIFORCE);
2013
2014 default:
2015
2/4
✓ Branch 0 taken 2439977 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2439977 times.
2439977 if(it>=0&&it<MAXLEVELS)
2016 {
2017 2439977 return (game->lvlitems[it]&liTRIFORCE);
2018 }
2019
2020 break;
2021 }
2022
2023 return 0;
2024 }
2025
2026 case itype_map: //it: -2=any, -1=current level, other=that level
2027 {
2028
1/3
✓ Branch 0 taken 12012783 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
12012783 switch(it)
2029 {
2030 case -2:
2031 {
2032 for(int32_t i=0; i<MAXLEVELS; i++)
2033 {
2034 if(game->lvlitems[i]&liMAP)
2035 {
2036 return true;
2037 }
2038 }
2039
2040 return false;
2041 }
2042
2043 case -1:
2044 return (game->lvlitems[dlevel]&liMAP)!=0;
2045
2046 default:
2047
2/4
✓ Branch 0 taken 12012783 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12012783 times.
12012783 if(it>=0&&it<MAXLEVELS)
2048 {
2049 12012783 return (game->lvlitems[it]&liMAP)!=0;
2050 }
2051
2052 break;
2053 }
2054
2055 return 0;
2056 }
2057
2058 case itype_compass: //it: -2=any, -1=current level, other=that level
2059 {
2060
1/3
✓ Branch 0 taken 3882589 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
3882589 switch(it)
2061 {
2062 case -2:
2063 {
2064 for(int32_t i=0; i<MAXLEVELS; i++)
2065 {
2066 if(game->lvlitems[i]&liCOMPASS)
2067 {
2068 return true;
2069 }
2070 }
2071
2072 return false;
2073 }
2074
2075 case -1:
2076 return (game->lvlitems[dlevel]&liCOMPASS)!=0;
2077
2078 default:
2079
2/4
✓ Branch 0 taken 3882589 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3882589 times.
✗ Branch 3 not taken.
3882589 if(it>=0&&it<MAXLEVELS)
2080 {
2081 3882589 return (game->lvlitems[it]&liCOMPASS)!=0;
2082 }
2083
2084 break;
2085 }
2086 return 0;
2087 }
2088
2089 case itype_bosskey: //it: -2=any, -1=current level, other=that level
2090 {
2091
1/3
✓ Branch 0 taken 27624 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
27624 switch(it)
2092 {
2093 case -2:
2094 {
2095 for(int32_t i=0; i<MAXLEVELS; i++)
2096 {
2097 if(game->lvlitems[i]&liBOSSKEY)
2098 {
2099 return true;
2100 }
2101 }
2102
2103 return false;
2104 }
2105
2106 case -1:
2107 return (game->lvlitems[dlevel]&liBOSSKEY)?1:0;
2108
2109 default:
2110
2/4
✓ Branch 0 taken 27624 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 27624 times.
27624 if(it>=0&&it<MAXLEVELS)
2111 {
2112 27624 return (game->lvlitems[it]&liBOSSKEY)?1:0;
2113 }
2114 break;
2115 }
2116 return 0;
2117 }
2118
2119 default:
2120 //it=(1<<(it-1));
2121 /*if (item_type>=itype_max)
2122 {
2123 system_pal();
2124 jwin_alert("Error","has_item exception",NULL,NULL,"O&K",NULL,'k',0,lfont);
2125 game_pal();
2126
2127 return false;
2128 }*/
2129 int32_t itemid = getItemID(itemsbuf, item_type, it);
2130
2131 if(itemid == -1)
2132 return false;
2133
2134 return game->get_item(itemid);
2135 }
2136 22449319 }
2137
2138
2139 69865212 int32_t current_item(int32_t item_type, bool checkenabled) //item currently being used
2140 {
2141
9/9
✓ Branch 0 taken 4086346 times.
✓ Branch 1 taken 37174444 times.
✓ Branch 2 taken 4086346 times.
✓ Branch 3 taken 4086346 times.
✓ Branch 4 taken 4086346 times.
✓ Branch 5 taken 4086346 times.
✓ Branch 6 taken 4086346 times.
✓ Branch 7 taken 4086346 times.
✓ Branch 8 taken 4086346 times.
69865212 switch(item_type)
2142 {
2143 case itype_clock:
2144 {
2145 4086346 int32_t maxid = getHighestLevelOfFamily(game, itemsbuf, item_type, checkenabled);
2146
2147
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4086346 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4086346 if(maxid != -1 && (itemsbuf[maxid].flags & ITEM_FLAG1)) //Active clock
2148 return itemsbuf[maxid].fam_type;
2149
2150 4086346 return has_item(itype_clock,1) ? 1 : 0;
2151 }
2152
2153 case itype_key:
2154 4086346 return game->get_keys();
2155
2156 case itype_lkey:
2157 4086346 return game->lvlkeys[get_dlevel()];
2158
2159 case itype_magiccontainer:
2160 4086346 return game->get_maxmagic()/game->get_mp_per_block();
2161
2162 case itype_triforcepiece:
2163 {
2164 4086346 int32_t count=0;
2165
2166
2/2
✓ Branch 0 taken 2092209152 times.
✓ Branch 1 taken 4086346 times.
2096295498 for(int32_t i=0; i<MAXLEVELS; i++)
2167 {
2168 2092209152 count+=(game->lvlitems[i]&liTRIFORCE)?1:0;
2169 2092209152 }
2170
2171 4086346 return count;
2172 }
2173
2174 case itype_map:
2175 {
2176 4086346 int32_t count=0;
2177
2178
2/2
✓ Branch 0 taken 2092209152 times.
✓ Branch 1 taken 4086346 times.
2096295498 for(int32_t i=0; i<MAXLEVELS; i++)
2179 {
2180 2092209152 count+=(game->lvlitems[i]&liMAP)?1:0;
2181 2092209152 }
2182
2183 4086346 return count;
2184 }
2185
2186 case itype_compass:
2187 {
2188 4086346 int32_t count=0;
2189
2190
2/2
✓ Branch 0 taken 2092209152 times.
✓ Branch 1 taken 4086346 times.
2096295498 for(int32_t i=0; i<MAXLEVELS; i++)
2191 {
2192 2092209152 count+=(game->lvlitems[i]&liCOMPASS)?1:0;
2193 2092209152 }
2194
2195 4086346 return count;
2196 }
2197
2198 case itype_bosskey:
2199 {
2200 4086346 int32_t count=0;
2201
2202
2/2
✓ Branch 0 taken 2092209152 times.
✓ Branch 1 taken 4086346 times.
2096295498 for(int32_t i=0; i<MAXLEVELS; i++)
2203 {
2204 2092209152 count+=(game->lvlitems[i]&liBOSSKEY)?1:0;
2205 2092209152 }
2206
2207 4086346 return count;
2208 }
2209
2210 default:
2211 37174444 int32_t maxid = getHighestLevelOfFamily(game, itemsbuf, item_type, checkenabled);
2212
2213
2/2
✓ Branch 0 taken 6971052 times.
✓ Branch 1 taken 30203392 times.
37174444 if(maxid == -1)
2214 30203392 return 0;
2215
2216 6971052 return itemsbuf[maxid].fam_type;
2217 }
2218 69865212 }
2219
2220 64438612 int32_t current_item(int32_t item_type) //item currently being used
2221 {
2222 64438612 return current_item(item_type, true);
2223 }
2224
2225 29 std::map<int32_t, int32_t> itemcache;
2226
2227 // Not actually used by anything at the moment...
2228 void removeFromItemCache(int32_t itemid)
2229 {
2230 itemcache.erase(itemid);
2231 }
2232
2233 19096 void flushItemCache()
2234 {
2235 19096 itemcache.clear();
2236
2237 //also fix the active subscreen if items were deleted -DD
2238
1/2
✓ Branch 0 taken 19096 times.
✗ Branch 1 not taken.
19096 if(game != NULL)
2239 {
2240 19096 verifyBothWeapons();
2241 19096 load_Sitems(&QMisc);
2242 19096 }
2243 19096 }
2244
2245 // This is used often, so it should be as direct as possible.
2246 2281812316 int32_t _c_item_id_internal(int32_t itemtype, bool checkmagic, bool jinx_check)
2247 {
2248
2/2
✓ Branch 0 taken 2233007959 times.
✓ Branch 1 taken 48804357 times.
2281812316 if(jinx_check)
2249 {
2250
4/4
✓ Branch 0 taken 31164925 times.
✓ Branch 1 taken 17639432 times.
✓ Branch 2 taken 27758483 times.
✓ Branch 3 taken 3406442 times.
48804357 if(!(HeroSwordClk() || HeroItemClk()))
2251 27758483 jinx_check = false; //not jinxed
2252 48804357 }
2253
4/4
✓ Branch 0 taken 2262408776 times.
✓ Branch 1 taken 19403540 times.
✓ Branch 2 taken 20897290 times.
✓ Branch 3 taken 2241511486 times.
2281812316 if(itemtype!=itype_ring && !jinx_check) // Rings must always be checked, as must jinx checks...
2254 {
2255 2241511486 std::map<int32_t,int32_t>::iterator res = itemcache.find(itemtype);
2256
2257
2/2
✓ Branch 0 taken 2231762974 times.
✓ Branch 1 taken 9748512 times.
2241511486 if(res != itemcache.end())
2258 2231762974 return res->second;
2259 9748512 }
2260
2261 50049342 int32_t result = -1;
2262 50049342 int32_t highestlevel = -1;
2263
2264
2/2
✓ Branch 0 taken 12812631552 times.
✓ Branch 1 taken 50049342 times.
12862680894 for(int32_t i=0; i<MAXITEMS; i++)
2265 {
2266
5/6
✓ Branch 0 taken 1030627526 times.
✓ Branch 1 taken 11782004026 times.
✓ Branch 2 taken 15409861 times.
✓ Branch 3 taken 1015217665 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 15409861 times.
12812631552 if(game->get_item(i) && itemsbuf[i].family==itemtype && !item_disabled(i))
2267 {
2268
4/4
✓ Branch 0 taken 4655389 times.
✓ Branch 1 taken 10754472 times.
✓ Branch 2 taken 1195206 times.
✓ Branch 3 taken 14214655 times.
15409861 if((checkmagic || itemtype == itype_ring) && itemtype != itype_magicring)
2269 {
2270 //printf("Checkmagic for %d: %d (%d %d)\n",i,checkmagiccost(i),itemsbuf[i].magic*game->get_magicdrainrate(),game->get_magic());
2271
2/2
✓ Branch 0 taken 14214535 times.
✓ Branch 1 taken 120 times.
14214655 if(!checkmagiccost(i))
2272 {
2273
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 108 times.
120 if ( !get_bit(quest_rules,qr_NEVERDISABLEAMMOONSUBSCREEN) ) continue; //don't make items with a magic cost vanish!! -Z
2274 12 }
2275 14214547 }
2276
6/6
✓ Branch 0 taken 13234243 times.
✓ Branch 1 taken 2175510 times.
✓ Branch 2 taken 229100 times.
✓ Branch 3 taken 1946410 times.
✓ Branch 4 taken 1458492 times.
✓ Branch 5 taken 717018 times.
15409753 if(jinx_check && (usesSwordJinx(i) ? HeroSwordClk() : HeroItemClk()))
2277 {
2278
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 717018 times.
717018 if(!(itemsbuf[i].flags & ITEM_JINX_IMMUNE))
2279 717018 continue;
2280 }
2281
2282
2/2
✓ Branch 0 taken 223586 times.
✓ Branch 1 taken 14469149 times.
14692735 if(itemsbuf[i].fam_type >= highestlevel)
2283 {
2284 14469149 highestlevel = itemsbuf[i].fam_type;
2285 14469149 result=i;
2286 14469149 }
2287 14692735 }
2288 12811914426 }
2289
2290
2/2
✓ Branch 0 taken 21045874 times.
✓ Branch 1 taken 29003468 times.
50049342 if(!jinx_check) //Can't cache jinx_check results
2291 29003468 itemcache[itemtype] = result;
2292 50049342 return result;
2293 2281812316 }
2294
2295 // 'jinx_check' indicates that the highest level item *immune to jinxes* should be returned.
2296 2261047025 int32_t current_item_id(int32_t itemtype, bool checkmagic, bool jinx_check)
2297 {
2298 2261047025 auto ret = _c_item_id_internal(itemtype,checkmagic,jinx_check);
2299
2/2
✓ Branch 0 taken 28039066 times.
✓ Branch 1 taken 2233007959 times.
2261047025 if(!jinx_check) //If not already a jinx-immune-only check...
2300 {
2301 //And the player IS jinxed...
2302
4/4
✓ Branch 0 taken 2215600032 times.
✓ Branch 1 taken 17407927 times.
✓ Branch 2 taken 3357364 times.
✓ Branch 3 taken 2212242668 times.
2233007959 if(HeroSwordClk() || HeroItemClk())
2303 {
2304 //Then do a jinx-immune-only check here
2305 20765291 auto ret2 = _c_item_id_internal(itemtype,checkmagic,true);
2306 //And *IF IT FINDS A VALID ITEM*, return that one instead! -Em
2307 //Should NOT need a compat rule, as this should always return -1 in old quests.
2308
2/2
✓ Branch 0 taken 974915 times.
✓ Branch 1 taken 19790376 times.
20765291 if(ret2 > -1) return ret2;
2309 19790376 }
2310 2232033044 }
2311 2260072110 return ret;
2312 2261047025 }
2313 14776608 int32_t current_item_power(int32_t itemtype)
2314 {
2315 14776608 int32_t result = current_item_id(itemtype,true);
2316
2/2
✓ Branch 0 taken 11445380 times.
✓ Branch 1 taken 3331228 times.
14776608 return (result<0) ? 0 : itemsbuf[result].power;
2317 }
2318
2319 7 int32_t heart_container_id()
2320 {
2321
1/2
✓ Branch 0 taken 203 times.
✗ Branch 1 not taken.
203 for(int32_t i=0; i<MAXITEMS; i++)
2322 {
2323
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 196 times.
203 if(itemsbuf[i].family == itype_heartcontainer)
2324 {
2325 7 return i;
2326 }
2327 196 }
2328 return -1;
2329 7 }
2330
2331 4086346 int32_t item_tile_mod()
2332 {
2333 4086346 int32_t tile=0;
2334
2335
2/2
✓ Branch 0 taken 975760 times.
✓ Branch 1 taken 3110586 times.
4086346 if(game->get_bombs())
2336 {
2337 3110586 int32_t itemid = current_item_id(itype_bomb,false);
2338
3/4
✓ Branch 0 taken 3029527 times.
✓ Branch 1 taken 81059 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3029527 times.
3110586 if(itemid > -1 && checkbunny(itemid))
2339 3029527 tile+=itemsbuf[itemid].ltm;
2340 3110586 }
2341
2342
2/2
✓ Branch 0 taken 3032663 times.
✓ Branch 1 taken 1053683 times.
4086346 if(game->get_sbombs())
2343 {
2344 1053683 int32_t itemid = current_item_id(itype_sbomb,false);
2345
3/4
✓ Branch 0 taken 1052255 times.
✓ Branch 1 taken 1428 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1052255 times.
1053683 if(itemid > -1 && checkbunny(itemid))
2346 1052255 tile+=itemsbuf[itemid].ltm;
2347 1053683 }
2348
2349
2/2
✓ Branch 0 taken 3998396 times.
✓ Branch 1 taken 87950 times.
4086346 if(current_item(itype_clock))
2350 {
2351 87950 int32_t itemid =
2352
1/2
✓ Branch 0 taken 87950 times.
✗ Branch 1 not taken.
87950 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2353 ? iClock
2354 : getHighestLevelEvenUnowned(itemsbuf, itype_clock);
2355
2/4
✓ Branch 0 taken 87950 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 87950 times.
87950 if(itemid > -1 && checkbunny(itemid))
2356 87950 tile+=itemsbuf[itemid].ltm;
2357 87950 }
2358
2359
2/2
✓ Branch 0 taken 3438526 times.
✓ Branch 1 taken 647820 times.
4086346 if(current_item(itype_key))
2360 {
2361 647820 int32_t itemid =
2362
1/2
✓ Branch 0 taken 647820 times.
✗ Branch 1 not taken.
647820 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2363 ? iKey
2364 : getHighestLevelEvenUnowned(itemsbuf, itype_key);
2365
2/4
✓ Branch 0 taken 647820 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 647820 times.
647820 if(itemid > -1 && checkbunny(itemid))
2366 647820 tile+=itemsbuf[itemid].ltm;
2367 647820 }
2368
2369
2/2
✓ Branch 0 taken 3927093 times.
✓ Branch 1 taken 159253 times.
4086346 if(current_item(itype_lkey))
2370 {
2371 159253 int32_t itemid =
2372
2/2
✓ Branch 0 taken 158343 times.
✓ Branch 1 taken 910 times.
159253 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2373 ? iLevelKey
2374 910 : getHighestLevelEvenUnowned(itemsbuf, itype_lkey);
2375
2/4
✓ Branch 0 taken 159253 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 159253 times.
159253 if(itemid > -1 && checkbunny(itemid))
2376 159253 tile+=itemsbuf[itemid].ltm;
2377 159253 }
2378
2379
2/2
✓ Branch 0 taken 886117 times.
✓ Branch 1 taken 3200229 times.
4086346 if(current_item(itype_map))
2380 {
2381 3200229 int32_t itemid =
2382
2/2
✓ Branch 0 taken 3199443 times.
✓ Branch 1 taken 786 times.
3200229 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2383 ? iMap
2384 786 : getHighestLevelEvenUnowned(itemsbuf, itype_map);
2385
2/4
✓ Branch 0 taken 3200229 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3200229 times.
3200229 if(itemid > -1 && checkbunny(itemid))
2386 3200229 tile+=itemsbuf[itemid].ltm;
2387 3200229 }
2388
2389
2/2
✓ Branch 0 taken 807819 times.
✓ Branch 1 taken 3278527 times.
4086346 if(current_item(itype_compass))
2390 {
2391 3278527 int32_t itemid =
2392
2/2
✓ Branch 0 taken 3197468 times.
✓ Branch 1 taken 81059 times.
3278527 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2393 ? iCompass
2394 81059 : getHighestLevelEvenUnowned(itemsbuf, itype_compass);
2395
2/4
✓ Branch 0 taken 3278527 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3278527 times.
3278527 if(itemid > -1 && checkbunny(itemid))
2396 3278527 tile+=itemsbuf[itemid].ltm;
2397 3278527 }
2398
2399
2/2
✓ Branch 0 taken 2275984 times.
✓ Branch 1 taken 1810362 times.
4086346 if(current_item(itype_bosskey))
2400 {
2401 1810362 int32_t itemid =
2402
1/2
✓ Branch 0 taken 1810362 times.
✗ Branch 1 not taken.
1810362 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2403 ? iBossKey
2404 : getHighestLevelEvenUnowned(itemsbuf, itype_bosskey);
2405
2/4
✓ Branch 0 taken 1810362 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1810362 times.
1810362 if(itemid > -1 && checkbunny(itemid))
2406 1810362 tile+=itemsbuf[itemid].ltm;
2407 1810362 }
2408
2409
2/2
✓ Branch 0 taken 2141126 times.
✓ Branch 1 taken 1945220 times.
4086346 if(current_item(itype_magiccontainer))
2410 {
2411 1945220 int32_t itemid =
2412
2/2
✓ Branch 0 taken 1852005 times.
✓ Branch 1 taken 93215 times.
1945220 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2413 ? iMagicC
2414 93215 : getHighestLevelEvenUnowned(itemsbuf, itype_magiccontainer);
2415
3/4
✓ Branch 0 taken 1945220 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1870 times.
✓ Branch 3 taken 1943350 times.
1945220 if(itemid > -1 && checkbunny(itemid))
2416 1943350 tile+=itemsbuf[itemid].ltm;
2417 1945220 }
2418
2419
2/2
✓ Branch 0 taken 1118041 times.
✓ Branch 1 taken 2968305 times.
4086346 if(current_item(itype_triforcepiece))
2420 {
2421 2968305 int32_t itemid =
2422
1/2
✓ Branch 0 taken 2968305 times.
✗ Branch 1 not taken.
2968305 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2423 ? iTriforce
2424 : getHighestLevelEvenUnowned(itemsbuf, itype_triforcepiece);
2425
2/4
✓ Branch 0 taken 2968305 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2968305 times.
2968305 if(itemid > -1 && checkbunny(itemid))
2426 2968305 tile+=itemsbuf[itemid].ltm;
2427 2968305 }
2428
2429
2/2
✓ Branch 0 taken 4086346 times.
✓ Branch 1 taken 2092209152 times.
2096295498 for(int32_t i=0; i<itype_max; i++)
2430 {
2431
2/2
✓ Branch 0 taken 2035907072 times.
✓ Branch 1 taken 56302080 times.
2092209152 if(!get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS))
2432 {
2433
2/2
✓ Branch 0 taken 1099650 times.
✓ Branch 1 taken 55202430 times.
56302080 switch(i)
2434 {
2435 case itype_bomb:
2436 case itype_sbomb:
2437 case itype_clock:
2438 case itype_key:
2439 case itype_lkey:
2440 case itype_map:
2441 case itype_compass:
2442 case itype_bosskey:
2443 case itype_magiccontainer:
2444 case itype_triforcepiece:
2445 1099650 continue; //already handled
2446 }
2447 55202430 }
2448 2091109502 int32_t itemid = current_item_id(i,false);
2449
2/2
✓ Branch 0 taken 2087023156 times.
✓ Branch 1 taken 4086346 times.
2091109502 if(i == itype_shield)
2450 4086346 itemid = getCurrentShield(false);
2451
2452
4/4
✓ Branch 0 taken 59139201 times.
✓ Branch 1 taken 2031970301 times.
✓ Branch 2 taken 100981 times.
✓ Branch 3 taken 59038220 times.
2091109502 if(itemid < 0 || !checkbunny(itemid))
2453 2032071282 continue;
2454
2455 59038220 itemdata const& itm = itemsbuf[itemid];
2456
2457
2/2
✓ Branch 0 taken 55529396 times.
✓ Branch 1 taken 3508824 times.
59038220 switch(itm.family)
2458 {
2459 case itype_shield:
2460
1/2
✓ Branch 0 taken 3508824 times.
✗ Branch 1 not taken.
3508824 if(itm.flags & ITEM_FLAG9) //active shield
2461 {
2462 if(!usingActiveShield(itemid))
2463 {
2464 tile+=itm.misc6; //'Inactive PTM'
2465 continue;
2466 }
2467 }
2468 3508824 break;
2469 }
2470
2471 59038220 tile+=itm.ltm;
2472 59038220 }
2473
2474 4086346 return tile;
2475 }
2476
2477 4086346 int32_t bunny_tile_mod()
2478 {
2479
2/2
✓ Branch 0 taken 1870 times.
✓ Branch 1 taken 4084476 times.
4086346 if(Hero.BunnyClock())
2480 {
2481 1870 return game->get_bunny_ltm();
2482 }
2483 4084476 return 0;
2484 4086346 }
2485
2486 // Hints are drawn on a separate layer to combo reveals.
2487 16332 void draw_lens_under(BITMAP *dest, bool layer)
2488 {
2489 //Lens flag 1: Replacement for qr_LENSHINTS; if set, lens will show hints. Does nothing if flag 2 is set.
2490 //Lens flag 2: Disable "hints", prevent rendering of Secret Combos
2491 //Lens flag 3: Don't show armos/chest/dive items
2492 //Lens flag 4: Show Raft Paths
2493 //Lens flag 5: Show Invisible Enemies
2494
4/4
✓ Branch 0 taken 456 times.
✓ Branch 1 taken 15876 times.
✓ Branch 2 taken 7938 times.
✓ Branch 3 taken 7938 times.
16332 bool hints = (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2) ? false : (layer && (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG1));
2495
2496 16332 int32_t strike_hint_table[11]=
2497 {
2498 mfARROW, mfBOMB, mfBRANG, mfWANDMAGIC,
2499 mfSWORD, mfREFMAGIC, mfHOOKSHOT,
2500 mfREFFIREBALL, mfHAMMER, mfSWORDBEAM, mfWAND
2501 };
2502
2503 // int32_t page = tmpscr->cpage;
2504 {
2505 16332 int32_t blink_rate=flash_reduction_enabled()?6:1;
2506 // int32_t temptimer=0;
2507 16332 int32_t tempitem, tempweapon=0;
2508 16332 strike_hint=strike_hint_table[strike_hint_counter];
2509
2510
2/2
✓ Branch 0 taken 15840 times.
✓ Branch 1 taken 492 times.
16332 if(strike_hint_timer>32)
2511 {
2512 492 strike_hint_timer=0;
2513 492 strike_hint_counter=((strike_hint_counter+1)%11);
2514 492 }
2515
2516 16332 ++strike_hint_timer;
2517
2518
2/2
✓ Branch 0 taken 2874432 times.
✓ Branch 1 taken 16332 times.
2890764 for(int32_t i=0; i<176; i++)
2519 {
2520 2874432 int32_t x = (i & 15) << 4;
2521 2874432 int32_t y = (i & 0xF0) + playing_field_offset;
2522 2874432 int32_t tempitemx=-16, tempitemy=-16;
2523 2874432 int32_t tempweaponx=-16, tempweapony=-16;
2524
2525
2/2
✓ Branch 0 taken 5748864 times.
✓ Branch 1 taken 2874432 times.
8623296 for(int32_t iter=0; iter<2; ++iter)
2526 {
2527 5748864 int32_t checkflag=0;
2528
2529
2/2
✓ Branch 0 taken 2874432 times.
✓ Branch 1 taken 2874432 times.
5748864 if(iter==0)
2530 {
2531 2874432 checkflag=combobuf[tmpscr->data[i]].flag;
2532 2874432 }
2533 else
2534 {
2535 2874432 checkflag=tmpscr->sflag[i];
2536 }
2537
2538
2/2
✓ Branch 0 taken 5747766 times.
✓ Branch 1 taken 1098 times.
5748864 if(checkflag==mfSTRIKE)
2539 {
2540
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 906 times.
1098 if(!hints)
2541 {
2542
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 906 times.
906 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSTRIKE],tmpscr->secretcset[sSTRIKE]);
2543 906 }
2544 else
2545 {
2546 192 checkflag = strike_hint;
2547 }
2548 1098 }
2549
2550
20/36
✓ Branch 0 taken 5706470 times.
✓ Branch 1 taken 3148 times.
✓ Branch 2 taken 3618 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2064 times.
✓ Branch 5 taken 28640 times.
✓ Branch 6 taken 2418 times.
✓ Branch 7 taken 504 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 814 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 33 times.
✓ Branch 15 taken 96 times.
✓ Branch 16 taken 24 times.
✓ Branch 17 taken 5 times.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 16 times.
✓ Branch 22 taken 16 times.
✓ Branch 23 taken 7 times.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✓ Branch 27 taken 16 times.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✓ Branch 31 taken 17 times.
✓ Branch 32 taken 35 times.
✓ Branch 33 taken 17 times.
✗ Branch 34 not taken.
✓ Branch 35 taken 906 times.
5748864 switch(checkflag)
2551 {
2552 case 0:
2553 case mfZELDA:
2554 case mfPUSHED:
2555 case mfENEMY0:
2556 case mfENEMY1:
2557 case mfENEMY2:
2558 case mfENEMY3:
2559 case mfENEMY4:
2560 case mfENEMY5:
2561 case mfENEMY6:
2562 case mfENEMY7:
2563 case mfENEMY8:
2564 case mfENEMY9:
2565 case mfSINGLE:
2566 case mfSINGLE16:
2567 case mfNOENEMY:
2568 case mfTRAP_H:
2569 case mfTRAP_V:
2570 case mfTRAP_4:
2571 case mfTRAP_LR:
2572 case mfTRAP_UD:
2573 case mfNOGROUNDENEMY:
2574 case mfNOBLOCKS:
2575 case mfSCRIPT1:
2576 case mfSCRIPT2:
2577 case mfSCRIPT3:
2578 case mfSCRIPT4:
2579 case mfSCRIPT5:
2580 case mfSCRIPT6:
2581 case mfSCRIPT7:
2582 case mfSCRIPT8:
2583 case mfSCRIPT9:
2584 case mfSCRIPT10:
2585 case mfSCRIPT11:
2586 case mfSCRIPT12:
2587 case mfSCRIPT13:
2588 case mfSCRIPT14:
2589 case mfSCRIPT15:
2590 case mfSCRIPT16:
2591 case mfSCRIPT17:
2592 case mfSCRIPT18:
2593 case mfSCRIPT19:
2594 case mfSCRIPT20:
2595 case mfPITHOLE:
2596 case mfPITFALLFLOOR:
2597 case mfLAVA:
2598 case mfICE:
2599 case mfICEDAMAGE:
2600 case mfDAMAGE1:
2601 case mfDAMAGE2:
2602 case mfDAMAGE4:
2603 case mfDAMAGE8:
2604 case mfDAMAGE16:
2605 case mfDAMAGE32:
2606 case mfFREEZEALL:
2607 case mfFREZEALLANSFFCS:
2608 case mfFREEZEFFCSOLY:
2609 case mfSCRITPTW1TRIG:
2610 case mfSCRITPTW2TRIG:
2611 case mfSCRITPTW3TRIG:
2612 case mfSCRITPTW4TRIG:
2613 case mfSCRITPTW5TRIG:
2614 case mfSCRITPTW6TRIG:
2615 case mfSCRITPTW7TRIG:
2616 case mfSCRITPTW8TRIG:
2617 case mfSCRITPTW9TRIG:
2618 case mfSCRITPTW10TRIG:
2619 case mfTROWEL:
2620 case mfTROWELNEXT:
2621 case mfTROWELSPECIALITEM:
2622 case mfSLASHPOT:
2623 case mfLIFTPOT:
2624 case mfLIFTORSLASH:
2625 case mfLIFTROCK:
2626 case mfLIFTROCKHEAVY:
2627 case mfDROPITEM:
2628 case mfSPECIALITEM:
2629 case mfDROPKEY:
2630 case mfDROPLKEY:
2631 case mfDROPCOMPASS:
2632 case mfDROPMAP:
2633 case mfDROPBOSSKEY:
2634 case mfSPAWNNPC:
2635 case mfSWITCHHOOK:
2636 case mfSIDEVIEWLADDER:
2637 case mfSIDEVIEWPLATFORM:
2638 case mfNOENEMYSPAWN:
2639 case mfENEMYALL:
2640 case mfNOMIRROR:
2641 case mfUNSAFEGROUND:
2642 case mf168:
2643 case mf169:
2644 case mf170:
2645 case mf171:
2646 case mf172:
2647 case mf173:
2648 case mf174:
2649 case mf175:
2650 case mf176:
2651 case mf177:
2652 case mf178:
2653 case mf179:
2654 case mf180:
2655 case mf181:
2656 case mf182:
2657 case mf183:
2658 case mf184:
2659 case mf185:
2660 case mf186:
2661 case mf187:
2662 case mf188:
2663 case mf189:
2664 case mf190:
2665 case mf191:
2666 case mf192:
2667 case mf193:
2668 case mf194:
2669 case mf195:
2670 case mf196:
2671 case mf197:
2672 case mf198:
2673 case mf199:
2674 case mf200:
2675 case mf201:
2676 case mf202:
2677 case mf203:
2678 case mf204:
2679 case mf205:
2680 case mf206:
2681 case mf207:
2682 case mf208:
2683 case mf209:
2684 case mf210:
2685 case mf211:
2686 case mf212:
2687 case mf213:
2688 case mf214:
2689 case mf215:
2690 case mf216:
2691 case mf217:
2692 case mf218:
2693 case mf219:
2694 case mf220:
2695 case mf221:
2696 case mf222:
2697 case mf223:
2698 case mf224:
2699 case mf225:
2700 case mf226:
2701 case mf227:
2702 case mf228:
2703 case mf229:
2704 case mf230:
2705 case mf231:
2706 case mf232:
2707 case mf233:
2708 case mf234:
2709 case mf235:
2710 case mf236:
2711 case mf237:
2712 case mf238:
2713 case mf239:
2714 case mf240:
2715 case mf241:
2716 case mf242:
2717 case mf243:
2718 case mf244:
2719 case mf245:
2720 case mf246:
2721 case mf247:
2722 case mf248:
2723 case mf249:
2724 case mf250:
2725 case mf251:
2726 case mf252:
2727 case mf253:
2728 case mf254:
2729 case mfEXTENDED:
2730 5706470 break;
2731
2732 case mfPUSHUD:
2733 case mfPUSHLR:
2734 case mfPUSH4:
2735 case mfPUSHU:
2736 case mfPUSHD:
2737 case mfPUSHL:
2738 case mfPUSHR:
2739 case mfPUSHUDNS:
2740 case mfPUSHLRNS:
2741 case mfPUSH4NS:
2742 case mfPUSHUNS:
2743 case mfPUSHDNS:
2744 case mfPUSHLNS:
2745 case mfPUSHRNS:
2746 case mfPUSHUDINS:
2747 case mfPUSHLRINS:
2748 case mfPUSH4INS:
2749 case mfPUSHUINS:
2750 case mfPUSHDINS:
2751 case mfPUSHLINS:
2752 case mfPUSHRINS:
2753
3/4
✓ Branch 0 taken 1829 times.
✓ Branch 1 taken 1319 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1829 times.
3148 if(!hints && ((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&16))
2754
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1829 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1829 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1829 || ((get_debug() && zc_getkey(KEY_N)) && (frame&16))))
2755 {
2756 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->undercombo,tmpscr->undercset);
2757 }
2758
2759
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3148 times.
3148 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2760
3/6
✓ Branch 0 taken 2438 times.
✓ Branch 1 taken 710 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 710 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3148 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2761 {
2762
2/2
✓ Branch 0 taken 1406 times.
✓ Branch 1 taken 1032 times.
2438 if(hints)
2763 {
2764
3/3
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 63 times.
✓ Branch 2 taken 897 times.
1032 switch(combobuf[tmpscr->data[i]].type)
2765 {
2766 case cPUSH_HEAVY:
2767 case cPUSH_HW:
2768 72 tempitem=getItemIDPower(itemsbuf,itype_bracelet,1);
2769 72 tempitemx=x, tempitemy=y;
2770
2771
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 72 times.
72 if(tempitem>-1)
2772 72 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2773
2774 72 break;
2775
2776 case cPUSH_HEAVY2:
2777 case cPUSH_HW2:
2778 63 tempitem=getItemIDPower(itemsbuf,itype_bracelet,2);
2779 63 tempitemx=x, tempitemy=y;
2780
2781
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 if(tempitem>-1)
2782 63 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2783
2784 63 break;
2785 }
2786 1032 }
2787 2438 }
2788
2789 3148 break;
2790
2791 case mfWHISTLE:
2792
1/2
✓ Branch 0 taken 2418 times.
✗ Branch 1 not taken.
2418 if(hints)
2793 {
2794 tempitem=getItemID(itemsbuf,itype_whistle,1);
2795
2796 if(tempitem<0) break;
2797
2798 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2799 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2800 {
2801 tempitemx=x;
2802 tempitemy=y;
2803 }
2804
2805 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2806 }
2807
2808 2418 break;
2809
2810 //Why is this here?
2811 case mfFAIRY:
2812 case mfMAGICFAIRY:
2813 case mfALLFAIRY:
2814 if(hints)
2815 {
2816 tempitem=getItemID(itemsbuf, itype_fairy,1);//iFairyMoving;
2817
2818 if(tempitem < 0) break;
2819
2820 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2821 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2822 {
2823 tempitemx=x;
2824 tempitemy=y;
2825 }
2826
2827 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2828 }
2829
2830 break;
2831
2832 case mfBCANDLE:
2833
2/2
✓ Branch 0 taken 252 times.
✓ Branch 1 taken 252 times.
504 if(!hints)
2834 {
2835
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 252 times.
252 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBCANDLE],tmpscr->secretcset[sBCANDLE]);
2836 252 }
2837 else
2838 {
2839 252 tempitem=getItemID(itemsbuf,itype_candle,1);
2840
2841
1/2
✓ Branch 0 taken 252 times.
✗ Branch 1 not taken.
252 if(tempitem<0) break;
2842
2843
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 252 times.
252 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2844
3/6
✓ Branch 0 taken 189 times.
✓ Branch 1 taken 63 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 63 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
252 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2845 {
2846 189 tempitemx=x;
2847 189 tempitemy=y;
2848 189 }
2849
2850 252 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2851 }
2852
2853 504 break;
2854
2855 case mfRCANDLE:
2856 if(!hints)
2857 {
2858 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sRCANDLE],tmpscr->secretcset[sRCANDLE]);
2859 }
2860 else
2861 {
2862 tempitem=getItemID(itemsbuf,itype_candle,2);
2863
2864 if(tempitem<0) break;
2865
2866 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2867 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2868 {
2869 tempitemx=x;
2870 tempitemy=y;
2871 }
2872
2873 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2874 }
2875
2876 break;
2877
2878 case mfWANDFIRE:
2879 if(!hints)
2880 {
2881 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWANDFIRE],tmpscr->secretcset[sWANDFIRE]);
2882 }
2883 else
2884 {
2885 tempitem=getItemID(itemsbuf,itype_wand,1);
2886
2887 if(tempitem<0) break;
2888
2889 tempweapon=wFire;
2890
2891 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2892 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2893 {
2894 tempitemx=x;
2895 tempitemy=y;
2896 }
2897 else
2898 {
2899 tempweaponx=x;
2900 tempweapony=y;
2901 }
2902
2903 putweapon(dest,tempweaponx,tempweapony,tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
2904 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2905 }
2906
2907 break;
2908
2909 case mfDINSFIRE:
2910 if(!hints)
2911 {
2912 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sDINSFIRE],tmpscr->secretcset[sDINSFIRE]);
2913 }
2914 else
2915 {
2916 tempitem=getItemID(itemsbuf,itype_dinsfire,1);
2917
2918 if(tempitem<0) break;
2919
2920 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2921 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2922 {
2923 tempitemx=x;
2924 tempitemy=y;
2925 }
2926
2927 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2928 }
2929
2930 break;
2931
2932 case mfARROW:
2933
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 732 times.
814 if(!hints)
2934 {
2935
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 732 times.
732 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sARROW],tmpscr->secretcset[sARROW]);
2936 732 }
2937 else
2938 {
2939 82 tempitem=getItemID(itemsbuf,itype_arrow,1);
2940
2941
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if(tempitem<0) break;
2942
2943
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2944
3/6
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 21 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 21 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
82 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2945 {
2946 61 tempitemx=x;
2947 61 tempitemy=y;
2948 61 }
2949
2950 82 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2951 }
2952
2953 814 break;
2954
2955 case mfSARROW:
2956 if(!hints)
2957 {
2958 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSARROW],tmpscr->secretcset[sSARROW]);
2959 }
2960 else
2961 {
2962 tempitem=getItemID(itemsbuf,itype_arrow,2);
2963
2964 if(tempitem<0) break;
2965
2966 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2967 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2968 {
2969 tempitemx=x;
2970 tempitemy=y;
2971 }
2972
2973 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2974 }
2975
2976 break;
2977
2978 case mfGARROW:
2979 if(!hints)
2980 {
2981 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sGARROW],tmpscr->secretcset[sGARROW]);
2982 }
2983 else
2984 {
2985 tempitem=getItemID(itemsbuf,itype_arrow,3);
2986
2987 if(tempitem<0) break;
2988
2989 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2990 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2991 {
2992 tempitemx=x;
2993 tempitemy=y;
2994 }
2995
2996 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2997 }
2998
2999 break;
3000
3001 case mfBOMB:
3002
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 16 times.
33 if(!hints)
3003 {
3004
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBOMB],tmpscr->secretcset[sBOMB]);
3005 16 }
3006 else
3007 {
3008 //tempitem=getItemID(itemsbuf,itype_bomb,1);
3009 17 tempweapon = wLitBomb;
3010
3011 //if (tempitem<0) break;
3012
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3013
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3014 {
3015 12 tempweaponx=x;
3016 12 tempweapony=y;
3017 12 }
3018
3019 17 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3020 }
3021
3022 33 break;
3023
3024 case mfSBOMB:
3025
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 48 times.
96 if(!hints)
3026 {
3027
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSBOMB],tmpscr->secretcset[sSBOMB]);
3028 48 }
3029 else
3030 {
3031 //tempitem=getItemID(itemsbuf,itype_sbomb,1);
3032 //if (tempitem<0) break;
3033 48 tempweapon = wLitSBomb;
3034
3035
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3036
3/6
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
48 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3037 {
3038 36 tempweaponx=x;
3039 36 tempweapony=y;
3040 36 }
3041
3042 48 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3043 }
3044
3045 96 break;
3046
3047 case mfARMOS_SECRET:
3048
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 12 times.
24 if(!hints)
3049 {
3050
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSTAIRS],tmpscr->secretcset[sSTAIRS]);
3051 12 }
3052 24 break;
3053
3054 case mfBRANG:
3055
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(!hints)
3056 {
3057 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBRANG],tmpscr->secretcset[sBRANG]);
3058 }
3059 else
3060 {
3061 5 tempitem=getItemID(itemsbuf,itype_brang,1);
3062
3063
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(tempitem<0) break;
3064
3065
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3066
3/6
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
5 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3067 {
3068 4 tempitemx=x;
3069 4 tempitemy=y;
3070 4 }
3071
3072 5 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3073 }
3074
3075 5 break;
3076
3077 case mfMBRANG:
3078 if(!hints)
3079 {
3080 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMBRANG],tmpscr->secretcset[sMBRANG]);
3081 }
3082 else
3083 {
3084 tempitem=getItemID(itemsbuf,itype_brang,2);
3085
3086 if(tempitem<0) break;
3087
3088 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3089 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3090 {
3091 tempitemx=x;
3092 tempitemy=y;
3093 }
3094
3095 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3096 }
3097
3098 break;
3099
3100 case mfFBRANG:
3101 if(!hints)
3102 {
3103 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sFBRANG],tmpscr->secretcset[sFBRANG]);
3104 }
3105 else
3106 {
3107 tempitem=getItemID(itemsbuf,itype_brang,3);
3108
3109 if(tempitem<0) break;
3110
3111 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3112 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3113 {
3114 tempitemx=x;
3115 tempitemy=y;
3116 }
3117
3118 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3119 }
3120
3121 break;
3122
3123 case mfWANDMAGIC:
3124 if(!hints)
3125 {
3126 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWANDMAGIC],tmpscr->secretcset[sWANDMAGIC]);
3127 }
3128 else
3129 {
3130 tempitem=getItemID(itemsbuf,itype_wand,1);
3131
3132 if(tempitem<0) break;
3133
3134 tempweapon=itemsbuf[tempitem].wpn3;
3135
3136 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3137 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3138 {
3139 tempitemx=x;
3140 tempitemy=y;
3141 }
3142 else
3143 {
3144 tempweaponx=x;
3145 tempweapony=y;
3146 --lens_hint_weapon[wMagic][4];
3147
3148 if(lens_hint_weapon[wMagic][4]<-8)
3149 {
3150 lens_hint_weapon[wMagic][4]=8;
3151 }
3152 }
3153
3154 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3155 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3156 }
3157
3158 break;
3159
3160 case mfREFMAGIC:
3161
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3162 {
3163 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sREFMAGIC],tmpscr->secretcset[sREFMAGIC]);
3164 }
3165 else
3166 {
3167 16 tempitem=getItemID(itemsbuf,itype_shield,3);
3168
3169
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3170
3171 16 tempweapon=ewMagic;
3172
3173
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3174
3/6
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3175 {
3176 13 tempitemx=x;
3177 13 tempitemy=y;
3178 13 }
3179 else
3180 {
3181 3 tempweaponx=x;
3182 3 tempweapony=y;
3183
3184
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 times.
3 if(lens_hint_weapon[ewMagic][2]==up)
3185 {
3186 1 --lens_hint_weapon[ewMagic][4];
3187 1 }
3188 else
3189 {
3190 2 ++lens_hint_weapon[ewMagic][4];
3191 }
3192
3193
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(lens_hint_weapon[ewMagic][4]>8)
3194 {
3195 lens_hint_weapon[ewMagic][2]=up;
3196 }
3197
3198
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2 times.
3 if(lens_hint_weapon[ewMagic][4]<=0)
3199 {
3200 2 lens_hint_weapon[ewMagic][2]=down;
3201 2 }
3202 }
3203
3204 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3205 16 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, lens_hint_weapon[ewMagic][2], lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3206 }
3207
3208 16 break;
3209
3210 case mfREFFIREBALL:
3211
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3212 {
3213 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sREFFIREBALL],tmpscr->secretcset[sREFFIREBALL]);
3214 }
3215 else
3216 {
3217 16 tempitem=getItemID(itemsbuf,itype_shield,3);
3218
3219
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3220
3221 16 tempweapon=ewFireball;
3222
3223
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3224
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3225 {
3226 12 tempitemx=x;
3227 12 tempitemy=y;
3228 12 tempweaponx=x;
3229 12 tempweapony=y;
3230 12 ++lens_hint_weapon[ewFireball][3];
3231
3232
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 1 times.
12 if(lens_hint_weapon[ewFireball][3]>8)
3233 {
3234 1 lens_hint_weapon[ewFireball][3]=-8;
3235 1 lens_hint_weapon[ewFireball][4]=8;
3236 1 }
3237
3238
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 4 times.
12 if(lens_hint_weapon[ewFireball][3]>0)
3239 {
3240 8 ++lens_hint_weapon[ewFireball][4];
3241 8 }
3242 else
3243 {
3244 4 --lens_hint_weapon[ewFireball][4];
3245 }
3246 12 }
3247
3248 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3249 16 putweapon(dest,tempweaponx+lens_hint_weapon[tempweapon][3],tempweapony+lens_hint_weapon[ewFireball][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3250 }
3251
3252 16 break;
3253
3254 case mfSWORD:
3255
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(!hints)
3256 {
3257 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSWORD],tmpscr->secretcset[sSWORD]);
3258 }
3259 else
3260 {
3261 7 tempitem=getItemID(itemsbuf,itype_sword,1);
3262
3263
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(tempitem<0) break;
3264
3265
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3266
3/6
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3267 {
3268 5 tempitemx=x;
3269 5 tempitemy=y;
3270 5 }
3271
3272 7 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3273 }
3274
3275 7 break;
3276
3277 case mfWSWORD:
3278 if(!hints)
3279 {
3280 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWSWORD],tmpscr->secretcset[sWSWORD]);
3281 }
3282 else
3283 {
3284 tempitem=getItemID(itemsbuf,itype_sword,2);
3285
3286 if(tempitem<0) break;
3287
3288 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3289 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3290 {
3291 tempitemx=x;
3292 tempitemy=y;
3293 }
3294
3295 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3296 }
3297
3298 break;
3299
3300 case mfMSWORD:
3301 if(!hints)
3302 {
3303 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMSWORD],tmpscr->secretcset[sMSWORD]);
3304 }
3305 else
3306 {
3307 tempitem=getItemID(itemsbuf,itype_sword,3);
3308
3309 if(tempitem<0) break;
3310
3311 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3312 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3313 {
3314 tempitemx=x;
3315 tempitemy=y;
3316 }
3317
3318 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3319 }
3320
3321 break;
3322
3323 case mfXSWORD:
3324 if(!hints)
3325 {
3326 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sXSWORD],tmpscr->secretcset[sXSWORD]);
3327 }
3328 else
3329 {
3330 tempitem=getItemID(itemsbuf,itype_sword,4);
3331
3332 if(tempitem<0) break;
3333
3334 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3335 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3336 {
3337 tempitemx=x;
3338 tempitemy=y;
3339 }
3340
3341 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3342 }
3343
3344 break;
3345
3346 case mfSWORDBEAM:
3347
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3348 {
3349 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSWORDBEAM],tmpscr->secretcset[sSWORDBEAM]);
3350 }
3351 else
3352 {
3353 16 tempitem=getItemID(itemsbuf,itype_sword,1);
3354
3355
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3356
3357
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3358
3/6
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3359 {
3360 11 tempitemx=x;
3361 11 tempitemy=y;
3362 11 }
3363
3364 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 1);
3365 }
3366
3367 16 break;
3368
3369 case mfWSWORDBEAM:
3370 if(!hints)
3371 {
3372 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWSWORDBEAM],tmpscr->secretcset[sWSWORDBEAM]);
3373 }
3374 else
3375 {
3376 tempitem=getItemID(itemsbuf,itype_sword,2);
3377
3378 if(tempitem<0) break;
3379
3380 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3381 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3382 {
3383 tempitemx=x;
3384 tempitemy=y;
3385 }
3386
3387 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 2);
3388 }
3389
3390 break;
3391
3392 case mfMSWORDBEAM:
3393 if(!hints)
3394 {
3395 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMSWORDBEAM],tmpscr->secretcset[sMSWORDBEAM]);
3396 }
3397 else
3398 {
3399 tempitem=getItemID(itemsbuf,itype_sword,3);
3400
3401 if(tempitem<0) break;
3402
3403 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3404 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3405 {
3406 tempitemx=x;
3407 tempitemy=y;
3408 }
3409
3410 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 3);
3411 }
3412
3413 break;
3414
3415 case mfXSWORDBEAM:
3416 if(!hints)
3417 {
3418 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sXSWORDBEAM],tmpscr->secretcset[sXSWORDBEAM]);
3419 }
3420 else
3421 {
3422 tempitem=getItemID(itemsbuf,itype_sword,4);
3423
3424 if(tempitem<0) break;
3425
3426 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3427 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3428 {
3429 tempitemx=x;
3430 tempitemy=y;
3431 }
3432
3433 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 4);
3434 }
3435
3436 break;
3437
3438 case mfHOOKSHOT:
3439
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!hints)
3440 {
3441 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sHOOKSHOT],tmpscr->secretcset[sHOOKSHOT]);
3442 }
3443 else
3444 {
3445 17 tempitem=getItemID(itemsbuf,itype_hookshot,1);
3446
3447
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(tempitem<0) break;
3448
3449
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3450
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3451 {
3452 12 tempitemx=x;
3453 12 tempitemy=y;
3454 12 }
3455
3456 17 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3457 }
3458
3459 17 break;
3460
3461 case mfWAND:
3462
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!hints)
3463 {
3464 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWAND],tmpscr->secretcset[sWAND]);
3465 }
3466 else
3467 {
3468 35 tempitem=getItemID(itemsbuf,itype_wand,1);
3469
3470
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(tempitem<0) break;
3471
3472
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3473
3/6
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
35 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3474 {
3475 28 tempitemx=x;
3476 28 tempitemy=y;
3477 28 }
3478
3479 35 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3480 }
3481
3482 35 break;
3483
3484 case mfHAMMER:
3485
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!hints)
3486 {
3487 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sHAMMER],tmpscr->secretcset[sHAMMER]);
3488 }
3489 else
3490 {
3491 17 tempitem=getItemID(itemsbuf,itype_hammer,1);
3492
3493
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(tempitem<0) break;
3494
3495
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3496
3/6
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3497 {
3498 13 tempitemx=x;
3499 13 tempitemy=y;
3500 13 }
3501
3502 17 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3503 }
3504
3505 17 break;
3506
3507 case mfARMOS_ITEM:
3508 case mfDIVE_ITEM:
3509
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2064 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2064 times.
2064 if((!getmapflag() || (tmpscr->flags9&fBELOWRETURN)) && !(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG3))
3510 {
3511 2064 putitem2(dest,x,y,tmpscr->catchall, lens_hint_item[tmpscr->catchall][0], lens_hint_item[tmpscr->catchall][1], 0);
3512 2064 }
3513 2064 break;
3514
3515 case 16:
3516 case 17:
3517 case 18:
3518 case 19:
3519 case 20:
3520 case 21:
3521 case 22:
3522 case 23:
3523 case 24:
3524 case 25:
3525 case 26:
3526 case 27:
3527 case 28:
3528 case 29:
3529 case 30:
3530 case 31:
3531
2/2
✓ Branch 0 taken 1008 times.
✓ Branch 1 taken 2610 times.
3618 if(!hints)
3532
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2610 times.
5220 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3533 2610 putcombo(dest,x,y,tmpscr->secretcombo[checkflag-16+4],tmpscr->secretcset[checkflag-16+4]);
3534
3535 3618 break;
3536 case mfSECRETSNEXT:
3537 if(!hints)
3538 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3539 putcombo(dest,x,y,tmpscr->data[i]+1,tmpscr->cset[i]);
3540
3541 break;
3542
3543 case mfSTRIKE:
3544
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 906 times.
906 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3545 {
3546 906 goto special;
3547 }
3548 else
3549 {
3550 break;
3551 }
3552
3553 28640 default: goto special;
3554
3555 special:
3556
8/8
✓ Branch 0 taken 14677 times.
✓ Branch 1 taken 14869 times.
✓ Branch 2 taken 473 times.
✓ Branch 3 taken 14204 times.
✓ Branch 4 taken 441 times.
✓ Branch 5 taken 32 times.
✓ Branch 6 taken 6108 times.
✓ Branch 7 taken 8128 times.
29546 if(layer && ((checkflag!=mfRAFT && checkflag!=mfRAFT_BRANCH&& checkflag!=mfRAFT_BOUNCE) ||(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG4)))
3557 {
3558
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 6549 times.
✓ Branch 2 taken 4913 times.
✓ Branch 3 taken 1636 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1636 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
6549 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate)) || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3559 {
3560 4913 rectfill(dest,x,y,x+15,y+15,WHITE);
3561 4913 }
3562 6549 }
3563
3564 29546 break;
3565 }
3566 5748864 }
3567 2874432 }
3568
3569
2/2
✓ Branch 0 taken 8166 times.
✓ Branch 1 taken 8166 times.
16332 if(layer)
3570 {
3571
2/2
✓ Branch 0 taken 7978 times.
✓ Branch 1 taken 188 times.
8166 if(tmpscr->door[0]==dWALK)
3572 188 rectfill(dest, 120, 16+playing_field_offset, 135, 31+playing_field_offset, WHITE);
3573
3574
2/2
✓ Branch 0 taken 7969 times.
✓ Branch 1 taken 197 times.
8166 if(tmpscr->door[1]==dWALK)
3575 197 rectfill(dest, 120, 144+playing_field_offset, 135, 159+playing_field_offset, WHITE);
3576
3577
2/2
✓ Branch 0 taken 8014 times.
✓ Branch 1 taken 152 times.
8166 if(tmpscr->door[2]==dWALK)
3578 152 rectfill(dest, 16, 80+playing_field_offset, 31, 95+playing_field_offset, WHITE);
3579
3580
2/2
✓ Branch 0 taken 7940 times.
✓ Branch 1 taken 226 times.
8166 if(tmpscr->door[3]==dWALK)
3581 226 rectfill(dest, 224, 80+playing_field_offset, 239, 95+playing_field_offset, WHITE);
3582
3583
2/2
✓ Branch 0 taken 8123 times.
✓ Branch 1 taken 43 times.
8166 if(tmpscr->door[0]==dBOMB)
3584 {
3585 43 showbombeddoor(dest, 0);
3586 43 }
3587
3588
2/2
✓ Branch 0 taken 8127 times.
✓ Branch 1 taken 39 times.
8166 if(tmpscr->door[1]==dBOMB)
3589 {
3590 39 showbombeddoor(dest, 1);
3591 39 }
3592
3593
1/2
✓ Branch 0 taken 8166 times.
✗ Branch 1 not taken.
8166 if(tmpscr->door[2]==dBOMB)
3594 {
3595 showbombeddoor(dest, 2);
3596 }
3597
3598
2/2
✓ Branch 0 taken 8129 times.
✓ Branch 1 taken 37 times.
8166 if(tmpscr->door[3]==dBOMB)
3599 {
3600 37 showbombeddoor(dest, 3);
3601 37 }
3602 8166 }
3603
3604
2/2
✓ Branch 0 taken 14298 times.
✓ Branch 1 taken 2034 times.
16332 if(tmpscr->stairx + tmpscr->stairy)
3605 {
3606
2/2
✓ Branch 0 taken 911 times.
✓ Branch 1 taken 1123 times.
2034 if(!hints)
3607 {
3608
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1123 times.
1123 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3609 1123 putcombo(dest,tmpscr->stairx,tmpscr->stairy+playing_field_offset,tmpscr->secretcombo[sSTAIRS],tmpscr->secretcset[sSTAIRS]);
3610 1123 }
3611 else
3612 {
3613
2/2
✓ Branch 0 taken 863 times.
✓ Branch 1 taken 48 times.
911 if(tmpscr->flags&fWHISTLE)
3614 {
3615 48 tempitem=getItemID(itemsbuf,itype_whistle,1);
3616 48 int32_t tempitemx=-16;
3617 48 int32_t tempitemy=-16;
3618
3619
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&(blink_rate/4)))
3620
3/6
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 24 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
48 || ((get_debug() && zc_getkey(KEY_N)) && (frame&(blink_rate/4))))
3621 {
3622 24 tempitemx=tmpscr->stairx;
3623 24 tempitemy=tmpscr->stairy+playing_field_offset;
3624 24 }
3625
3626 48 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3627 48 }
3628 }
3629 2034 }
3630 }
3631 16332 }
3632
3633 BITMAP *lens_scr_d; // The "d" is for "destructible"!
3634
3635 7997 void draw_lens_over()
3636 {
3637 // Oh, what the heck.
3638 static BITMAP *lens_scr = NULL;
3639 static int32_t last_width = -1;
3640 7997 int32_t width = itemsbuf[current_item_id(itype_lens,true)].misc1;
3641
3642 // Only redraw the circle if the size has changed
3643
2/2
✓ Branch 0 taken 7992 times.
✓ Branch 1 taken 5 times.
7997 if(width != last_width)
3644 {
3645
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(lens_scr == NULL)
3646 {
3647 5 lens_scr = create_bitmap_ex(8,2*288,2*(240-playing_field_offset));
3648 5 }
3649
3650 5 clear_to_color(lens_scr, BLACK);
3651 5 circlefill(lens_scr, 288, 240-playing_field_offset, width, 0);
3652 5 circle(lens_scr, 288, 240-playing_field_offset, width+2, 0);
3653 5 circle(lens_scr, 288, 240-playing_field_offset, width+5, 0);
3654 5 last_width=width;
3655 5 }
3656
3657 7997 masked_blit(lens_scr, framebuf, 288-(HeroX()+8), 240-playing_field_offset-(HeroY()+8), 0, playing_field_offset, 256, 168);
3658 7997 }
3659
3660 //----------------------------------------------------------------
3661
3662 30701 void draw_wavy(BITMAP *source, BITMAP *target, int32_t amplitude, bool interpol)
3663 {
3664 //recreating a big bitmap every frame is highly sluggish.
3665
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 30699 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
30701 static BITMAP *wavebuf = create_bitmap_ex(8,288,240-original_playing_field_offset);
3666 30701 clear_to_color(wavebuf, BLACK);
3667 30701 blit(source,wavebuf,0,original_playing_field_offset,16,0,256,224-original_playing_field_offset);
3668
3669 int32_t ofs;
3670 // int32_t amplitude=8;
3671 // int32_t wavelength=4;
3672
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30701 times.
30701 amplitude = zc_min(2048,amplitude); // some arbitrary limit to prevent crashing
3673
3/6
✓ Branch 0 taken 30701 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 30701 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 30701 times.
30701 if(flash_reduction_enabled() && !get_bit(quest_rules, qr_WAVY_NO_EPILEPSY)) amplitude = zc_min(16,amplitude);
3674 30701 int32_t amp2=168;
3675
2/4
✓ Branch 0 taken 30701 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 30701 times.
30701 if(flash_reduction_enabled() && !get_bit(quest_rules, qr_WAVY_NO_EPILEPSY_2)) amp2*=2;
3676 30701 int32_t i=frame%amp2;
3677
3678
2/2
✓ Branch 0 taken 5157768 times.
✓ Branch 1 taken 30701 times.
5188469 for(int32_t j=0; j<168; j++)
3679 {
3680
3/4
✓ Branch 0 taken 2578884 times.
✓ Branch 1 taken 2578884 times.
✓ Branch 2 taken 2578884 times.
✗ Branch 3 not taken.
5157768 if(j&1 && interpol)
3681 {
3682 // Add 288*2048 to ensure it's never negative. It'll get modded out.
3683 ofs=288*2048+int32_t(zc::math::Sin((double(i+j)*2*PI/amp2))*amplitude);
3684 }
3685 else
3686 {
3687 5157768 ofs=288*2048-int32_t(zc::math::Sin((double(i+j)*2*PI/amp2))*amplitude);
3688 }
3689
3690
1/2
✓ Branch 0 taken 5157768 times.
✗ Branch 1 not taken.
5157768 if(ofs)
3691 {
3692
2/2
✓ Branch 0 taken 1320388608 times.
✓ Branch 1 taken 5157768 times.
1325546376 for(int32_t k=0; k<256; k++)
3693 {
3694 1320388608 target->line[j+original_playing_field_offset][k]=wavebuf->line[j][(k+ofs+16)%288];
3695 1320388608 }
3696 5157768 }
3697 5157768 }
3698 30701 }
3699
3700 2832 void draw_fuzzy(int32_t fuzz)
3701 // draws from right half of scrollbuf to framebuf
3702 {
3703 int32_t firstx, firsty, xstep, ystep, i, y, dx, dy;
3704 byte *start, *si, *di;
3705
3706
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2832 times.
2832 if(fuzz<1)
3707 fuzz = 1;
3708
3709 2832 xstep = 128%fuzz;
3710
3711
2/2
✓ Branch 0 taken 590 times.
✓ Branch 1 taken 2242 times.
2832 if(xstep > 0)
3712 2242 xstep = fuzz-xstep;
3713
3714 2832 ystep = 112%fuzz;
3715
3716
2/2
✓ Branch 0 taken 826 times.
✓ Branch 1 taken 2006 times.
2832 if(ystep > 0)
3717 2006 ystep = fuzz-ystep;
3718
3719 2832 firsty = 1;
3720
3721
2/2
✓ Branch 0 taken 2832 times.
✓ Branch 1 taken 102188 times.
105020 for(y=0; y<224;)
3722 {
3723 102188 start = &(scrollbuf->line[y][256]);
3724
3725
4/4
✓ Branch 0 taken 100772 times.
✓ Branch 1 taken 635784 times.
✓ Branch 2 taken 634368 times.
✓ Branch 3 taken 102188 times.
736556 for(dy=0; dy<ystep && dy+y<224; dy++)
3726 {
3727 634368 si = start;
3728 634368 di = &(framebuf->line[y+dy][0]);
3729 634368 i = xstep;
3730 634368 firstx = 1;
3731
3732
2/2
✓ Branch 0 taken 162398208 times.
✓ Branch 1 taken 634368 times.
163032576 for(dx=0; dx<256; dx++)
3733 {
3734 162398208 *(di++) = *si;
3735
3736
2/2
✓ Branch 0 taken 136838464 times.
✓ Branch 1 taken 25559744 times.
162398208 if(++i >= fuzz)
3737 {
3738
2/2
✓ Branch 0 taken 24925376 times.
✓ Branch 1 taken 634368 times.
25559744 if(!firstx)
3739 24925376 si += fuzz;
3740 else
3741 {
3742 634368 si += fuzz-xstep;
3743 634368 firstx = 0;
3744 }
3745
3746 25559744 i = 0;
3747 25559744 }
3748 162398208 }
3749 634368 }
3750
3751
2/2
✓ Branch 0 taken 99356 times.
✓ Branch 1 taken 2832 times.
102188 if(!firsty)
3752 99356 y += fuzz;
3753 else
3754 {
3755 2832 y += ystep;
3756 2832 ystep = fuzz;
3757 2832 firsty = 0;
3758 }
3759 }
3760 2832 }
3761
3762 6510665 void updatescr(bool allowwavy)
3763 {
3764
4/6
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 6510636 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 29 times.
✓ Branch 4 taken 29 times.
✗ Branch 5 not taken.
6510665 static BITMAP *wavybuf = create_bitmap_ex(8,256,224);
3765
4/6
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 6510636 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 29 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 29 times.
6510665 static BITMAP *panorama = create_bitmap_ex(8,256,224);
3766
3767
2/2
✓ Branch 0 taken 6484961 times.
✓ Branch 1 taken 25704 times.
6510665 if(toogam)
3768 {
3769 25704 textout_ex(framebuf,font,"no walls",8,216,1,-1);
3770 25704 }
3771
3772
1/2
✓ Branch 0 taken 6510665 times.
✗ Branch 1 not taken.
6510665 if(Showpal)
3773 dump_pal(framebuf);
3774
3775
2/2
✓ Branch 0 taken 6428643 times.
✓ Branch 1 taken 82022 times.
6510665 if(!Playing)
3776 82022 black_opening_count=0;
3777
3778
2/2
✓ Branch 0 taken 6472715 times.
✓ Branch 1 taken 37950 times.
6510665 if(black_opening_count<0) //shape is opening up
3779 {
3780 37950 black_opening(framebuf,black_opening_x,black_opening_y,(66+black_opening_count),66);
3781
3782
2/4
✓ Branch 0 taken 37950 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 37950 times.
37950 if(Advance||(!Paused))
3783 {
3784 37950 ++black_opening_count;
3785 37950 }
3786 37950 }
3787
2/2
✓ Branch 0 taken 6458459 times.
✓ Branch 1 taken 14256 times.
6472715 else if(black_opening_count>0) //shape is closing
3788 {
3789 14256 black_opening(framebuf,black_opening_x,black_opening_y,black_opening_count,66);
3790
3791
2/4
✓ Branch 0 taken 14256 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14256 times.
14256 if(Advance||(!Paused))
3792 {
3793 14256 --black_opening_count;
3794 14256 }
3795 14256 }
3796
3797
3/4
✓ Branch 0 taken 6459250 times.
✓ Branch 1 taken 51415 times.
✓ Branch 2 taken 6459250 times.
✗ Branch 3 not taken.
6510665 if(black_opening_count==0&&black_opening_shape==bosFADEBLACK)
3798 {
3799 black_opening_shape = bosCIRCLE;
3800 memcpy(RAMpal, tempblackpal, PAL_SIZE*sizeof(RGB));
3801 refreshTints();
3802 refreshpal=true;
3803 }
3804
3805
2/2
✓ Branch 0 taken 6298112 times.
✓ Branch 1 taken 212553 times.
6510665 if(refreshpal)
3806 {
3807 212553 refreshpal=false;
3808 212553 RAMpal[253] = _RGB(0,0,0);
3809 212553 RAMpal[254] = _RGB(63,63,63);
3810 212553 hw_palette = &RAMpal;
3811 212553 update_hw_pal = true;
3812
3813 212553 create_rgb_table(&rgb_table, RAMpal, NULL);
3814 212553 create_zc_trans_table(&trans_table, RAMpal, 128, 128, 128);
3815 212553 memcpy(&trans_table2, &trans_table, sizeof(COLOR_MAP));
3816
3817
2/2
✓ Branch 0 taken 54413568 times.
✓ Branch 1 taken 212553 times.
54626121 for(int32_t q=0; q<PAL_SIZE; q++)
3818 {
3819 54413568 trans_table2.data[0][q] = q;
3820 54413568 trans_table2.data[q][q] = q;
3821 54413568 }
3822 212553 }
3823
3824 6510665 bool clearwavy = (wavy <= 0);
3825
3826
2/2
✓ Branch 0 taken 7245 times.
✓ Branch 1 taken 6503420 times.
6510665 if(wavy <= 0)
3827 {
3828 // So far one thing can alter wavy apart from scripts: Wavy DMaps.
3829 6503420 wavy = (DMaps[currdmap].flags&dmfWAVY ? 4 : 0);
3830 6503420 }
3831
3832 6510665 blit(framebuf, wavybuf, 0, 0, 0, 0, 256, 224);
3833
3834
6/6
✓ Branch 0 taken 30951 times.
✓ Branch 1 taken 6479714 times.
✓ Branch 2 taken 30829 times.
✓ Branch 3 taken 122 times.
✓ Branch 4 taken 128 times.
✓ Branch 5 taken 30701 times.
6510665 if(wavy && Playing && allowwavy)
3835 {
3836 30701 draw_wavy(framebuf, wavybuf, wavy,false);
3837 30701 }
3838
3839
2/2
✓ Branch 0 taken 6503420 times.
✓ Branch 1 taken 7245 times.
6510665 if(clearwavy)
3840 6503420 wavy = 0; // Wavy was set by a DMap flag. Clear it.
3841
2/4
✓ Branch 0 taken 7245 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7245 times.
7245 else if(Playing && !Paused)
3842 7245 wavy--; // Wavy was set by a script. Decrement it.
3843
3844
5/6
✓ Branch 0 taken 6428643 times.
✓ Branch 1 taken 82022 times.
✓ Branch 2 taken 125857 times.
✓ Branch 3 taken 6302786 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 125857 times.
6510665 if(Playing && msgpos && !screenscrolling)
3845 {
3846
1/2
✓ Branch 0 taken 125857 times.
✗ Branch 1 not taken.
125857 if(!(msg_bg_display_buf->clip))
3847 125857 blit_msgstr_bg(framebuf,0,0,0,playing_field_offset,256,168);
3848
1/2
✓ Branch 0 taken 125857 times.
✗ Branch 1 not taken.
125857 if(!(msg_portrait_display_buf->clip))
3849 125857 blit_msgstr_prt(framebuf,0,0,0,playing_field_offset,256,168);
3850
1/2
✓ Branch 0 taken 125857 times.
✗ Branch 1 not taken.
125857 if(!(msg_txt_display_buf->clip))
3851 125857 blit_msgstr_fg(framebuf,0,0,0,playing_field_offset,256,168);
3852 125857 }
3853
3854 /*
3855 if(!(msg_txt_display_buf->clip) && Playing && msgpos && !screenscrolling)
3856 {
3857 BITMAP* subBmp = 0;
3858 masked_blit(msg_txt_display_buf,subBmp,0,0,0,playing_field_offset,256,168);
3859 // masked_blit(msg_txt_display_buf,subBmp,0,playing_field_offset,256,168);
3860 draw_trans_sprite(framebuf, subBmp, 0, playing_field_offset);
3861 destroy_bitmap(subBmp);
3862 //void draw_sprite_ex(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t mode, int32_t flip);
3863 // masked_blit(msg_txt_display_buf,framebuf,0,0,0,playing_field_offset,256,168);
3864 //void masked_blit(BITMAP *source, BITMAP *dest, int32_t source_x, int32_t source_y, int32_t dest_x, int32_t dest_y, int32_t width, int32_t height);
3865 }
3866 */
3867
3868
2/2
✓ Branch 0 taken 6485486 times.
✓ Branch 1 taken 25179 times.
6510665 bool nosubscr = (tmpscr->flags3&fNOSUBSCR && !(tmpscr->flags3&fNOSUBSCROFFSET));
3869
3870
2/2
✓ Branch 0 taken 6485486 times.
✓ Branch 1 taken 25179 times.
6510665 if(nosubscr)
3871 {
3872 25179 rectfill(panorama,0,0,255,passive_subscreen_height/2,0);
3873 25179 rectfill(panorama,0,168+passive_subscreen_height/2,255,168+passive_subscreen_height-1,0);
3874 25179 blit(wavybuf,panorama,0,playing_field_offset,0,passive_subscreen_height/2,256,224-passive_subscreen_height);
3875 25179 }
3876
3877 //TODO: Optimize blit 'overcalls' -Gleeok
3878
2/2
✓ Branch 0 taken 25179 times.
✓ Branch 1 taken 6485486 times.
6510665 BITMAP *source = nosubscr ? panorama : wavybuf;
3879 6510665 blit(source,framebuf,0,0,0,0,256,224);
3880
3881 6510665 update_hw_screen();
3882 6510665 }
3883
3884 //----------------------------------------------------------------
3885
3886 PALETTE sys_pal;
3887
3888 int32_t onGUISnapshot()
3889 {
3890 char buf[200];
3891 int32_t num=0;
3892 bool realpal=(key[KEY_ZC_LCONTROL] || key[KEY_ZC_RCONTROL]);
3893 do
3894 {
3895 sprintf(buf, "%szc_screen%05d.%s", get_snap_str(), ++num, snapshotformat_str[SnapshotFormat][1]);
3896 }
3897 while(num<99999 && exists(buf));
3898
3899 BITMAP *b = create_bitmap_ex(8,resx,resy);
3900
3901 if(b)
3902 {
3903 if(MenuOpen)
3904 {
3905 //Cannot load game's palette while GUI elements are in focus. -Z
3906 //If there is a way to do this, then I have missed it.
3907 /*
3908 game_pal();
3909 RAMpal[253] = _RGB(0,0,0);
3910 RAMpal[254] = _RGB(63,63,63);
3911 set_palette_range(RAMpal,0,255,false);
3912 memcpy(RAMpal, snappal, sizeof(snappal));
3913 create_rgb_table(&rgb_table, RAMpal, NULL);
3914 create_zc_trans_table(&trans_table, RAMpal, 128, 128, 128);
3915 memcpy(&trans_table2, &trans_table, sizeof(COLOR_MAP));
3916
3917 for(int32_t q=0; q<PAL_SIZE; q++)
3918 {
3919 trans_table2.data[0][q] = q;
3920 trans_table2.data[q][q] = q;
3921 }
3922 */
3923 //ringcolor(false);
3924 //get_palette(RAMpal);
3925 blit(screen,b,0,0,0,0,resx,resy);
3926 //al_trace("Menu Open\n");
3927 //game_pal();
3928 //PALETTE temppal;
3929 //get_palette(temppal);
3930 //system_pal();
3931 save_bitmap(buf,b,sys_pal);
3932 //save_bitmap(buf,b,RAMpal);
3933 //save_bitmap(buf,b,snappal);
3934 }
3935 else
3936 {
3937 blit(screen,b,0,0,0,0,resx,resy);
3938 save_bitmap(buf,b,realpal?sys_pal:RAMpal);
3939 }
3940 destroy_bitmap(b);
3941 }
3942
3943 return D_O_K;
3944 }
3945
3946 int32_t onNonGUISnapshot()
3947 {
3948 PALETTE temppal;
3949 get_palette(temppal);
3950 bool realpal=(zc_getkey(KEY_ZC_LCONTROL, true) || zc_getkey(KEY_ZC_RCONTROL, true));
3951
3952 char buf[200];
3953 int32_t num=0;
3954
3955 do
3956 {
3957 sprintf(buf, "%szc_screen%05d.%s", get_snap_str(), ++num, snapshotformat_str[SnapshotFormat][1]);
3958 }
3959 while(num<99999 && exists(buf));
3960
3961 save_bitmap(buf,framebuf,realpal?temppal:RAMpal);
3962
3963 return D_O_K;
3964 }
3965
3966 int32_t onSnapshot()
3967 {
3968 if(zc_getkey(KEY_LSHIFT, true)||zc_getkey(KEY_RSHIFT, true))
3969 {
3970 onGUISnapshot();
3971 }
3972 else
3973 {
3974 onNonGUISnapshot();
3975 }
3976
3977 return D_O_K;
3978 }
3979
3980 int32_t onSaveMapPic()
3981 {
3982 int32_t mapres2 = 0;
3983 char buf[200];
3984 int32_t num=0;
3985 mapscr tmpscr_b[2];
3986 mapscr tmpscr_c[6];
3987 BITMAP* _screen_draw_buffer = NULL;
3988 _screen_draw_buffer = create_bitmap_ex(8,256,224);
3989 set_clip_state(_screen_draw_buffer,1);
3990
3991 for(int32_t i=0; i<6; ++i)
3992 {
3993 tmpscr_c[i] = tmpscr2[i];
3994 tmpscr2[i].zero_memory();
3995
3996 if(i>=2)
3997 {
3998 continue;
3999 }
4000
4001 tmpscr_b[i] = tmpscr[i];
4002 tmpscr[i].zero_memory();
4003 }
4004
4005 do
4006 {
4007 sprintf(buf, "%szc_screen%05d.png", get_snap_str(), ++num);
4008 }
4009 while(num<99999 && exists(buf));
4010
4011 BITMAP* mappic = NULL;
4012
4013
4014 bool done=false, redraw=true;
4015
4016 mappic = create_bitmap_ex(8,(256*16)>>mapres,(176*8)>>mapres);
4017
4018 if(!mappic)
4019 {
4020 system_pal();
4021 jwin_alert("View Map","Not enough memory.",NULL,NULL,"OK",NULL,13,27,lfont);
4022 game_pal();
4023 return D_O_K;;
4024 }
4025
4026 // draw the map
4027 set_clip_rect(_screen_draw_buffer, 0, 0, _screen_draw_buffer->w, _screen_draw_buffer->h);
4028
4029 for(int32_t y=0; y<8; y++)
4030 {
4031 for(int32_t x=0; x<16; x++)
4032 {
4033 if(!displayOnMap(x, y))
4034 {
4035 rectfill(_screen_draw_buffer, 0, 0, 255, 223, WHITE);
4036 }
4037 else
4038 {
4039 int32_t s = (y<<4) + x;
4040 loadscr2(1,s,-1);
4041
4042 for(int32_t i=0; i<6; i++)
4043 {
4044 if(tmpscr[1].layermap[i]<=0)
4045 continue;
4046
4047 if((ZCMaps[tmpscr[1].layermap[i]-1].tileWidth==ZCMaps[currmap].tileWidth) &&
4048 (ZCMaps[tmpscr[1].layermap[i]-1].tileHeight==ZCMaps[currmap].tileHeight))
4049 {
4050 const int32_t _mapsSize = (ZCMaps[currmap].tileWidth)*(ZCMaps[currmap].tileHeight);
4051
4052 tmpscr2[i]=TheMaps[(tmpscr[1].layermap[i]-1)*MAPSCRS+tmpscr[1].layerscreen[i]];
4053 }
4054 }
4055
4056 if(XOR((tmpscr+1)->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(_screen_draw_buffer, 0, 2, tmpscr+1, -256, playing_field_offset, 2);
4057
4058 if(XOR((tmpscr+1)->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(_screen_draw_buffer, 0, 3, tmpscr+1, -256, playing_field_offset, 2);
4059
4060 putscr(_screen_draw_buffer,256,0,tmpscr+1);
4061 do_layer(_screen_draw_buffer, 0, 1, tmpscr+1, -256, playing_field_offset, 2);
4062
4063 if(!XOR((tmpscr+1)->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(_screen_draw_buffer, 0, 2, tmpscr+1, -256, playing_field_offset, 2);
4064
4065 putscrdoors(_screen_draw_buffer,256,0,tmpscr+1);
4066 do_layer(_screen_draw_buffer, -2, 0, tmpscr+1, -256, playing_field_offset, 2);
4067 if(get_bit(quest_rules, qr_PUSHBLOCK_LAYER_1_2))
4068 {
4069 do_layer(_screen_draw_buffer, -2, 1, tmpscr+1, -256, playing_field_offset, 2);
4070 do_layer(_screen_draw_buffer, -2, 2, tmpscr+1, -256, playing_field_offset, 2);
4071 }
4072 do_layer(_screen_draw_buffer, -3, 0, tmpscr+1, -256, playing_field_offset, 2); // Freeform combos!
4073
4074 if(!XOR((tmpscr+1)->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(_screen_draw_buffer, 0, 3, tmpscr+1, -256, playing_field_offset, 2);
4075
4076 do_layer(_screen_draw_buffer, 0, 4, tmpscr+1, -256, playing_field_offset, 2);
4077 do_layer(_screen_draw_buffer, -1, 0, tmpscr+1, -256, playing_field_offset, 2);
4078 if(get_bit(quest_rules, qr_OVERHEAD_COMBOS_L1_L2))
4079 {
4080 do_layer(_screen_draw_buffer, -1, 1, tmpscr+1, -256, playing_field_offset, 2);
4081 do_layer(_screen_draw_buffer, -1, 2, tmpscr+1, -256, playing_field_offset, 2);
4082 }
4083 do_layer(_screen_draw_buffer, 0, 5, tmpscr+1, -256, playing_field_offset, 2);
4084 do_layer(_screen_draw_buffer, 0, 6, tmpscr+1, -256, playing_field_offset, 2);
4085
4086 }
4087
4088 stretch_blit(_screen_draw_buffer, mappic, 256, 0, 256, 176, x<<(8-mapres), (y*176)>>mapres, 256>>mapres, 176>>mapres);
4089 }
4090 }
4091
4092 for(int32_t i=0; i<6; ++i)
4093 {
4094 tmpscr2[i]=tmpscr_c[i];
4095
4096 if(i>=2)
4097 {
4098 continue;
4099 }
4100
4101 tmpscr[i]=tmpscr_b[i];
4102 }
4103
4104 save_bitmap(buf,mappic,RAMpal);
4105 destroy_bitmap(mappic);
4106 destroy_bitmap(_screen_draw_buffer);
4107 return D_O_K;
4108 }
4109
4110 /*
4111 int32_t onSaveMapPic()
4112 {
4113 BITMAP* mappic = NULL;
4114 BITMAP* _screen_draw_buffer = NULL;
4115 _screen_draw_buffer = create_bitmap_ex(8,256,224);
4116 int32_t mapres2 = 0;
4117 char buf[20];
4118 int32_t num=0;
4119 set_clip_state(_screen_draw_buffer,1);
4120 set_clip_rect(_screen_draw_buffer,0,0,_screen_draw_buffer->w, _screen_draw_buffer->h);
4121
4122 do
4123 {
4124 sprintf(buf, "zelda%03d.png", ++num);
4125 }
4126 while(num<999 && exists(buf));
4127
4128 // if(!mappic) {
4129 mappic = create_bitmap_ex(8,(256*16)>>mapres2,(176*8)>>mapres2);
4130
4131 if(!mappic)
4132 {
4133 system_pal();
4134 jwin_alert("Save Map Picture","Not enough memory.",NULL,NULL,"OK",NULL,13,27,lfont);
4135 game_pal();
4136 return D_O_K;
4137 }
4138
4139 // }
4140
4141 int32_t layermap, layerscreen;
4142 int32_t x2=0;
4143
4144 // draw the map
4145 for(int32_t y=0; y<8; y++)
4146 {
4147 for(int32_t x=0; x<16; x++)
4148 {
4149 int32_t s = (y<<4) + x;
4150
4151 if(!displayOnMap(x, y))
4152 {
4153 rectfill(_screen_draw_buffer, 0, 0, 255, 223, WHITE);
4154 }
4155 else
4156 {
4157 loadscr(TEMPSCR_FUNCTION_SWAP_SPACE,currdmap,s,-1,false);
4158 putscr(_screen_draw_buffer, 0, 0, tmpscr+1);
4159
4160 for(int32_t k=0; k<4; k++)
4161 {
4162 if(k==2)
4163 {
4164 putscrdoors(_screen_draw_buffer, 0, 0, tmpscr+1);
4165 }
4166
4167 layermap=TheMaps[currmap*MAPSCRS+s].layermap[k]-1;
4168
4169 if(layermap>-1)
4170 {
4171 layerscreen=layermap*MAPSCRS+TheMaps[currmap*MAPSCRS+s].layerscreen[k];
4172
4173 if(TheMaps[currmap*MAPSCRS+s].layeropacity[k]==255)
4174 {
4175 for(int32_t i=0; i<176; i++)
4176 {
4177 overcombo(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),TheMaps[layerscreen].data[i],TheMaps[layerscreen].cset[i]);
4178 }
4179 }
4180 else
4181 {
4182 for(int32_t i=0; i<176; i++)
4183 {
4184 overcombotranslucent(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),TheMaps[layerscreen].data[i],TheMaps[layerscreen].cset[i],TheMaps[currmap*MAPSCRS+s].layeropacity[k]);
4185 }
4186 }
4187 }
4188 }
4189
4190 for(int32_t i=0; i<176; i++)
4191 {
4192 // if (COMBOTYPE((i&15)<<4,i&0xF0)==cOLD_OVERHEAD)
4193 if(combo_class_buf[COMBOTYPE((i&15)<<4,i&0xF0)].overhead)
4194 {
4195 overcombo(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),MAPCOMBO((i&15)<<4,i&0xF0),MAPCSET((i&15)<<4,i&0xF0));
4196 }
4197 }
4198
4199 for(int32_t k=4; k<6; k++)
4200 {
4201 layermap=TheMaps[currmap*MAPSCRS+s].layermap[k]-1;
4202
4203 if(layermap>-1)
4204 {
4205 layerscreen=layermap*MAPSCRS+TheMaps[currmap*MAPSCRS+s].layerscreen[k];
4206
4207 if(TheMaps[currmap*MAPSCRS+s].layeropacity[k]==255)
4208 {
4209 for(int32_t i=0; i<176; i++)
4210 {
4211 overcombo(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),TheMaps[layerscreen].data[i],TheMaps[layerscreen].cset[i]);
4212 }
4213 }
4214 else
4215 {
4216 for(int32_t i=0; i<176; i++)
4217 {
4218 overcombotranslucent(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),TheMaps[layerscreen].data[i],TheMaps[layerscreen].cset[i],TheMaps[currmap*MAPSCRS+s].layeropacity[k]);
4219 }
4220 }
4221 }
4222 }
4223 }
4224
4225 stretch_blit(_screen_draw_buffer, mappic, 0, 0, 256, 176,
4226 x<<(8-mapres2), (y*176)>>mapres2, 256>>mapres2, 176>>mapres2);
4227 }
4228
4229 }
4230
4231 save_bitmap(buf,mappic,RAMpal);
4232 destroy_bitmap(mappic);
4233 destroy_bitmap(_screen_draw_buffer);
4234 return D_O_K;
4235 }
4236 */
4237
4238 14 void f_Quit(int32_t type)
4239 {
4240
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
14 if(type==qQUIT && !Playing)
4241 return;
4242
4243 14 bool from_menu = is_sys_pal;
4244
4245
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(!from_menu)
4246 {
4247 14 music_pause();
4248 14 pause_all_sfx();
4249 14 }
4250 14 enter_sys_pal();
4251 14 clear_keybuf();
4252
4253
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14 times.
14 if (replay_is_active() && replay_get_version() <= 9)
4254 14 replay_poll();
4255
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if (replay_is_replaying())
4256 14 replay_peek_quit();
4257
4258
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if (!replay_is_replaying())
4259 switch(type)
4260 {
4261 case qQUIT:
4262 onQuit();
4263 break;
4264
4265 case qRESET:
4266 onReset();
4267 break;
4268
4269 case qEXIT:
4270 onExit();
4271 break;
4272 }
4273
4274
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(Quit)
4275 {
4276 14 kill_sfx();
4277 14 music_stop();
4278 14 exit_sys_pal();
4279 14 update_hw_screen();
4280 14 }
4281 else
4282 {
4283 exit_sys_pal();
4284 if(!from_menu)
4285 {
4286 music_resume();
4287 resume_all_sfx();
4288 }
4289 }
4290
4291
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(!from_menu)
4292 14 show_mouse(NULL);
4293 14 eat_buttons();
4294
4295 14 zc_readrawkey(KEY_ESC);
4296
4297 14 zc_readrawkey(KEY_ENTER);
4298 14 }
4299
4300 //----------------------------------------------------------------
4301
4302 int32_t onNoWalls()
4303 {
4304 cheats_enqueue(Cheat::Walls);
4305 return D_O_K;
4306 }
4307
4308 int32_t onIgnoreSideview()
4309 {
4310 cheats_enqueue(Cheat::IgnoreSideView);
4311 return D_O_K;
4312 }
4313
4314 6510614 int32_t input_idle(bool checkmouse)
4315 {
4316 static int32_t mx, my, mz, mb;
4317
4318
4/6
✓ Branch 0 taken 6510614 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1621032 times.
✓ Branch 3 taken 4889582 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1621032 times.
8131646 if(keypressed() || zc_key_pressed() ||
4319
4/8
✓ Branch 0 taken 1621032 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1621032 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1621032 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1621032 times.
✗ Branch 7 not taken.
1621032 (checkmouse && (mx != mouse_x || my != mouse_y || mz != mouse_z || mb != mouse_b)))
4320 {
4321 4889582 idle_count = 0;
4322
4323
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4889582 times.
4889582 if(active_count < MAX_ACTIVE)
4324 {
4325 4889582 ++active_count;
4326 4889582 }
4327 4889582 }
4328
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1621032 times.
1621032 else if(idle_count < MAX_IDLE)
4329 {
4330 1621032 ++idle_count;
4331 1621032 active_count = 0;
4332 1621032 }
4333
4334 6510614 mx = mouse_x;
4335 6510614 my = mouse_y;
4336 6510614 mz = mouse_z;
4337 6510614 mb = mouse_b;
4338
4339 6510614 return idle_count;
4340 }
4341
4342 int32_t onGoFast()
4343 {
4344 cheats_enqueue(Cheat::Fast);
4345 return D_O_K;
4346 }
4347
4348 int32_t onKillCheat()
4349 {
4350 cheats_enqueue(Cheat::Kill);
4351 return D_O_K;
4352 }
4353
4354 int32_t onSecretsCheat()
4355 {
4356 cheats_enqueue(Cheat::TrigSecrets);
4357 return D_O_K;
4358 }
4359 int32_t onSecretsCheatPerm()
4360 {
4361 cheats_enqueue(Cheat::TrigSecretsPerm);
4362 return D_O_K;
4363 }
4364
4365 int32_t onShowLayer0()
4366 {
4367 show_layer_0 = !show_layer_0;
4368 return D_O_K;
4369 }
4370 int32_t onShowLayer1()
4371 {
4372 show_layer_1 = !show_layer_1;
4373 return D_O_K;
4374 }
4375 int32_t onShowLayer2()
4376 {
4377 show_layer_2 = !show_layer_2;
4378 return D_O_K;
4379 }
4380 int32_t onShowLayer3()
4381 {
4382 show_layer_3 = !show_layer_3;
4383 return D_O_K;
4384 }
4385 int32_t onShowLayer4()
4386 {
4387 show_layer_4 = !show_layer_4;
4388 return D_O_K;
4389 }
4390 int32_t onShowLayer5()
4391 {
4392 show_layer_5 = !show_layer_5;
4393 return D_O_K;
4394 }
4395 int32_t onShowLayer6()
4396 {
4397 show_layer_6 = !show_layer_6;
4398 return D_O_K;
4399 }
4400 int32_t onShowLayerO()
4401 {
4402 show_layer_over=!show_layer_over;
4403 return D_O_K;
4404 }
4405 int32_t onShowLayerP()
4406 {
4407 show_layer_push=!show_layer_push;
4408 return D_O_K;
4409 }
4410 int32_t onShowLayerS()
4411 {
4412 show_sprites=!show_sprites;
4413 return D_O_K;
4414 }
4415 int32_t onShowLayerF()
4416 {
4417 show_ffcs=!show_ffcs;
4418 return D_O_K;
4419 }
4420 int32_t onShowLayerW()
4421 {
4422 show_walkflags=!show_walkflags;
4423 if(show_walkflags)
4424 show_effectflags = false;
4425 return D_O_K;
4426 }
4427 int32_t onShowLayerE()
4428 {
4429 show_effectflags=!show_effectflags;
4430 if(show_effectflags)
4431 show_walkflags = false;
4432 return D_O_K;
4433 }
4434 int32_t onShowFFScripts()
4435 {
4436 show_ff_scripts=!show_ff_scripts;
4437 return D_O_K;
4438 }
4439 int32_t onShowHitboxes()
4440 {
4441 show_hitboxes=!show_hitboxes;
4442 return D_O_K;
4443 }
4444 int32_t onShowInfoOpacity()
4445 {
4446 info_opacity = vbound(getnumber("Debug Info Opacity",info_opacity),0,255);
4447 zc_set_config("zc","debug_info_opacity",info_opacity);
4448 return D_O_K;
4449 }
4450
4451 int32_t onLightSwitch()
4452 {
4453 cheats_enqueue(Cheat::Light);
4454 return D_O_K;
4455 }
4456
4457 int32_t onGoTo();
4458 int32_t onGoToComplete();
4459
4460 6510614 void syskeys()
4461 {
4462 6510614 update_system_keys();
4463
4464 int32_t oldtitle_version;
4465
4466
1/2
✓ Branch 0 taken 6510614 times.
✗ Branch 1 not taken.
6510614 if(close_button_quit)
4467 {
4468 close_button_quit=false;
4469 f_Quit(qEXIT);
4470 }
4471
4472 6510614 poll_joystick();
4473
4474
2/10
✓ Branch 0 taken 6510614 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6510614 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
6510614 if(rMbtn() || (gui_mouse_b() && !mouse_down && ClickToFreeze &&!disableClickToFreeze))
4475 {
4476 oldtitle_version=title_version;
4477 System();
4478 }
4479
4480 6510614 mouse_down=gui_mouse_b();
4481
4482
1/2
✓ Branch 0 taken 6510614 times.
✗ Branch 1 not taken.
6510614 if(zc_read_system_key(KEY_F1))
4483 {
4484 if(zc_get_system_key(KEY_ZC_LCONTROL) || zc_get_system_key(KEY_ZC_RCONTROL))
4485 {
4486 halt=!halt;
4487 //zinit.subscreen=(zinit.subscreen+1)%ssdtMAX;
4488 }
4489 else
4490 {
4491 Throttlefps=!Throttlefps;
4492 zc_set_config(cfg_sect,"throttlefps", (int32_t)Throttlefps);
4493 logic_counter=0;
4494 }
4495 }
4496
4497 // if(zc_readkey(KEY_F1)) Vsync=!Vsync;
4498 /*
4499 if(zc_readkey(KEY_F1)) set_bit(QHeader.rules4,qr4_NEWENEMYTILES,
4500 1-((get_bit(QHeader.rules4,qr4_NEWENEMYTILES))));
4501 */
4502
4503
1/2
✓ Branch 0 taken 6510614 times.
✗ Branch 1 not taken.
6510614 if(zc_read_system_key(KEY_F2))
4504 {
4505 ShowFPS=!ShowFPS;
4506 zc_set_config(cfg_sect,"showfps",(int32_t)ShowFPS);
4507 }
4508
4509
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6510614 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6510614 if(zc_read_system_key(KEY_F3) && Playing) Paused=!Paused;
4510
4511
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6510614 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6510614 if(zc_read_system_key(KEY_F4) && Playing)
4512 {
4513 Paused=true;
4514 Advance=true;
4515 }
4516
4517
1/2
✓ Branch 0 taken 6510614 times.
✗ Branch 1 not taken.
6510614 if(zc_read_system_key(KEY_F6)) onTryQuit();
4518
4519 #ifndef ALLEGRO_MACOSX
4520
1/2
✓ Branch 0 taken 6510614 times.
✗ Branch 1 not taken.
6510614 if(zc_read_system_key(KEY_F9)) f_Quit(qRESET);
4521
4522
1/2
✓ Branch 0 taken 6510614 times.
✗ Branch 1 not taken.
6510614 if(zc_read_system_key(KEY_F10)) f_Quit(qEXIT);
4523 #else
4524 if(zc_read_system_key(KEY_F7)) f_Quit(qRESET);
4525
4526 if(zc_read_system_key(KEY_F8)) f_Quit(qEXIT);
4527 #endif
4528
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 6510614 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
6510614 if(zc_read_system_key(KEY_F5)&&(Playing && currscr<128 && DMaps[currdmap].flags&dmfVIEWMAP)) onSaveMapPic();
4529
4530
1/2
✓ Branch 0 taken 6510614 times.
✗ Branch 1 not taken.
6510614 if (zc_read_system_key(KEY_F12))
4531 {
4532 onSnapshot();
4533 }
4534
4535
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6510614 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6510614 if(debug_enabled && zc_read_system_key(KEY_TAB))
4536 set_debug(!get_debug());
4537
4538
1/2
✓ Branch 0 taken 6510614 times.
✗ Branch 1 not taken.
6510614 if(CheatModifierKeys())
4539 {
4540 for(Cheat c = (Cheat)1; c < Cheat::Last; c = (Cheat)(c+1))
4541 {
4542 if(!bindable_cheat(c))
4543 continue;
4544 if(get_debug() || cheat >= cheat_lvl(c))
4545 {
4546 if(checkcheat(c))
4547 cheats_hit_bind(c);
4548 }
4549 }
4550 }
4551
4552
1/2
✓ Branch 0 taken 6510614 times.
✗ Branch 1 not taken.
6510614 if(volkeys)
4553 {
4554 if(zc_read_system_key(KEY_PGUP)) master_volume(-1,midi_volume+8);
4555
4556 if(zc_read_system_key(KEY_PGDN)) master_volume(-1,midi_volume==255?248:midi_volume-8);
4557
4558 if(zc_read_system_key(KEY_HOME)) master_volume(digi_volume+8,-1);
4559
4560 if(zc_read_system_key(KEY_END)) master_volume(digi_volume==255?248:digi_volume-8,-1);
4561 }
4562
4563
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 6510614 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
6510614 if(!get_debug() || !SystemKeys || replay_is_replaying())
4564 6510614 goto bottom;
4565
4566 if(zc_readkey(KEY_D))
4567 {
4568 details = !details;
4569 rectfill(screen,0,0,319,7,BLACK);
4570 rectfill(screen,0,8,31,239,BLACK);
4571 rectfill(screen,288,8,319,239,BLACK);
4572 rectfill(screen,32,232,287,239,BLACK);
4573 }
4574
4575 if(zc_readkey(KEY_P)) Paused=!Paused;
4576
4577 //if(zc_readkey(KEY_P)) centerHero();
4578 if(zc_readkey(KEY_A))
4579 {
4580 Paused=true;
4581 Advance=true;
4582 }
4583
4584 if(zc_readkey(KEY_G)) db=(db==999)?0:999;
4585 #ifndef ALLEGRO_MACOSX
4586 if(zc_readkey(KEY_F8)) Showpal=!Showpal;
4587
4588 if(zc_readkey(KEY_F7))
4589 {
4590 Matrix(ss_speed, ss_density, 0);
4591 game_pal();
4592 }
4593 #else
4594 // The reason these are different on Mac in the first place is that
4595 // the OS doesn't let us use F9 and F10...
4596 if(zc_readkey(KEY_F10)) Showpal=!Showpal;
4597
4598 if(zc_readkey(KEY_F9))
4599 {
4600 Matrix(ss_speed, ss_density, 0);
4601 game_pal();
4602 }
4603 #endif
4604 if(zc_readkey(KEY_PLUS_PAD) || zc_readkey(KEY_EQUALS))
4605 {
4606 //change containers
4607 if(zc_getkey(KEY_ZC_LCONTROL) || zc_getkey(KEY_ZC_RCONTROL))
4608 {
4609 //magic containers
4610 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4611 {
4612 game->set_maxmagic(zc_min(game->get_maxmagic()+game->get_mp_per_block(),game->get_mp_per_block()*8));
4613 }
4614 else
4615 {
4616 game->set_maxlife(zc_min(game->get_maxlife()+game->get_hp_per_heart(),game->get_hp_per_heart()*24));
4617 }
4618 }
4619 else
4620 {
4621 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4622 {
4623 game->set_magic(zc_min(game->get_magic()+1,game->get_maxmagic()));
4624 }
4625 else
4626 {
4627 game->set_life(zc_min(game->get_life()+1,game->get_maxlife()));
4628 }
4629 }
4630 }
4631
4632 if(zc_readkey(KEY_MINUS_PAD) || zc_readkey(KEY_MINUS))
4633 {
4634 //change containers
4635 if(zc_getkey(KEY_ZC_LCONTROL) || zc_getkey(KEY_ZC_RCONTROL))
4636 {
4637 //magic containers
4638 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4639 {
4640 game->set_maxmagic(zc_max(game->get_maxmagic()-game->get_mp_per_block(),0));
4641 game->set_magic(zc_min(game->get_maxmagic(), game->get_magic()));
4642 //heart containers
4643 }
4644 else
4645 {
4646 game->set_maxlife(zc_max(game->get_maxlife()-game->get_hp_per_heart(),game->get_hp_per_heart()));
4647 game->set_life(zc_min(game->get_maxlife(), game->get_life()));
4648 }
4649 }
4650 else
4651 {
4652 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4653 {
4654 game->set_magic(zc_max(game->get_magic()-1,0));
4655 }
4656 else
4657 {
4658 game->set_life(zc_max(game->get_life()-1,0));
4659 }
4660 }
4661 }
4662
4663 if(zc_readkey(KEY_COMMA)) jukebox(currmidi-1);
4664
4665 if(zc_readkey(KEY_STOP)) jukebox(currmidi+1);
4666
4667 verifyBothWeapons();
4668
4669 bottom:
4670
4671
1/2
✓ Branch 0 taken 6510614 times.
✗ Branch 1 not taken.
6510614 if(input_idle(true) > after_time())
4672 {
4673 Matrix(ss_speed, ss_density, 0);
4674 game_pal();
4675 }
4676 6510614 }
4677
4678 330136 void checkQuitKeys()
4679 {
4680 #ifndef ALLEGRO_MACOSX
4681
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 330136 times.
330136 if(key[KEY_F9]) f_Quit(qRESET);
4682
4683
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 330136 times.
330136 if(key[KEY_F10]) f_Quit(qEXIT);
4684 #else
4685 if(key[KEY_F7]) f_Quit(qRESET);
4686
4687 if(key[KEY_F8]) f_Quit(qEXIT);
4688 #endif
4689 330136 }
4690
4691 6510614 bool CheatModifierKeys()
4692 {
4693 // Cheats are replayed via the X cheat step, no need to check for keyboard input
4694 // to trigger cheats.
4695
1/2
✓ Branch 0 taken 6510614 times.
✗ Branch 1 not taken.
6510614 if (replay_is_replaying())
4696 6510614 return false;
4697
4698 if ( ( cheat_modifier_keys[0] > 0 && key[cheat_modifier_keys[0]] ) ||
4699 ( cheat_modifier_keys[1] > 0 && key[cheat_modifier_keys[1]] ) ||
4700 (cheat_modifier_keys[0] <= 0 && cheat_modifier_keys[1] <= 0))
4701 {
4702 if ( ( cheat_modifier_keys[2] <= 0 || key[cheat_modifier_keys[2]] ) ||
4703 ( cheat_modifier_keys[3] > 0 && key[cheat_modifier_keys[3]] ) ||
4704 (cheat_modifier_keys[2] <= 0 && cheat_modifier_keys[3] <= 0))
4705 {
4706 return true;
4707 }
4708 }
4709 return false;
4710 6510614 }
4711
4712 //99:05:54, for some reason?
4713 #define OLDMAXTIME 21405240
4714 //9000:00:00, the highest even-thousand hour fitting within 32b signed. This is 375 *DAYS*.
4715 #define MAXTIME 1944000000
4716
4717 6510665 void advanceframe(bool allowwavy, bool sfxcleanup, bool allowF6Script)
4718 {
4719
2/2
✓ Branch 0 taken 6242564 times.
✓ Branch 1 taken 268101 times.
6510665 if(zcmusic!=NULL)
4720 {
4721 268101 zcmusic_poll();
4722 268101 }
4723
4724 6510665 updatescr(allowwavy);
4725
4726 6510665 Advance=false;
4727
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 6510665 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 6510665 times.
6510665 while(Paused && !Advance && !Quit)
4728 {
4729 // have to call this, otherwise we'll get an infinite loop
4730 syskeys();
4731 if(allowF6Script)
4732 {
4733 FFCore.runF6Engine();
4734 }
4735 throttleFPS();
4736
4737 #ifdef _WIN32
4738
4739 if(use_dwm_flush)
4740 {
4741 do_DwmFlush();
4742 }
4743
4744 #endif
4745
4746 // to keep music playing
4747 if(zcmusic!=NULL)
4748 {
4749 zcmusic_poll();
4750 }
4751
4752 update_hw_screen();
4753 }
4754
4755
2/2
✓ Branch 0 taken 6510624 times.
✓ Branch 1 taken 41 times.
6510665 if(Quit)
4756 41 return;
4757
4758
3/4
✓ Branch 0 taken 6428635 times.
✓ Branch 1 taken 81989 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6428635 times.
6510624 if(Playing && game->get_time()<unsigned(get_bit(quest_rules,qr_GREATER_MAX_TIME) ? MAXTIME : OLDMAXTIME))
4759 6428635 game->change_time(1);
4760
4761
2/4
✓ Branch 0 taken 6510624 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6510624 times.
6510624 if (!replay_is_active() || replay_get_version() >= 11)
4762 for (int i = 0; i < ZC_CONTROL_STATES; i++)
4763 down_control_states[i] = raw_control_state[i];
4764
4765
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 6510622 times.
6510624 if (replay_is_active())
4766 {
4767
2/2
✓ Branch 0 taken 1270461 times.
✓ Branch 1 taken 5240161 times.
6510622 if (replay_get_version() >= 3)
4768 5240161 replay_poll();
4769
4770
5/6
✓ Branch 0 taken 6510614 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3089962 times.
✓ Branch 3 taken 3420652 times.
✓ Branch 4 taken 100535 times.
✓ Branch 5 taken 2989427 times.
6510622 if (replay_get_version() >= 11 || (replay_get_version() >= 6 && replay_get_version() < 8))
4771 100535 replay_peek_input();
4772 6510614 }
4773
4774 6510624 load_control_called_this_frame = false;
4775
4776 6510624 poll_keyboard();
4777 6510624 update_keys();
4778
4779 6510624 ++frame;
4780
4781
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 6510614 times.
6510624 if (replay_is_replaying())
4782 6510614 replay_do_cheats();
4783 6510624 syskeys();
4784
4785 // The mouse variables can change from the mouse thread at anytime during a frame,
4786 // so save the result at the start so that replaying is consistent.
4787 6510624 script_mouse_x = gui_mouse_x();
4788 6510624 script_mouse_y = gui_mouse_y();
4789 6510624 script_mouse_z = mouse_z;
4790 6510624 script_mouse_b = mouse_b;
4791
4792 // Cheats used via the System menu (called by syskeys) will call cheats_enqueue. syskeys
4793 // is called just above, and in the paused loop above, so the queue-and-defer-slightly
4794 // approach here means it doesn't matter which call adds the cheat.
4795 6510624 cheats_execute_queued();
4796
4797
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 6510614 times.
6510624 if (replay_is_replaying())
4798 6510614 replay_peek_quit();
4799
2/2
✓ Branch 0 taken 6510610 times.
✓ Branch 1 taken 14 times.
6510624 if (GameFlags & GAMEFLAG_TRYQUIT)
4800 14 replay_step_quit(0);
4801
2/2
✓ Branch 0 taken 1835 times.
✓ Branch 1 taken 6508789 times.
6510624 if(allowF6Script)
4802 6508789 FFCore.runF6Engine();
4803
2/2
✓ Branch 0 taken 6510449 times.
✓ Branch 1 taken 175 times.
6510624 if (Quit)
4804 175 replay_step_quit(Quit);
4805 // Someday... maybe install a Turbo button here?
4806 6510624 throttleFPS();
4807
4808 #ifdef _WIN32
4809
4810 if(use_dwm_flush)
4811 {
4812 do_DwmFlush();
4813 }
4814
4815 #endif
4816
4817 //textprintf_ex(screen,font,0,72,254,BLACK,"%d %d", lastentrance, lastentrance_dmap);
4818
2/2
✓ Branch 0 taken 29901 times.
✓ Branch 1 taken 6480723 times.
6510624 if(sfxcleanup)
4819 6480723 sfx_cleanup();
4820 6510665 }
4821
4822 59 void zapout()
4823 {
4824 59 set_clip_rect(scrollbuf, 0, 0, scrollbuf->w, scrollbuf->h);
4825 59 blit(framebuf,scrollbuf,0,0,256,0,256,224);
4826
4827 59 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4828 59 script_drawing_commands.Clear();
4829
4830 // zap out
4831
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 1416 times.
1475 for(int32_t i=1; i<=24; i++)
4832 {
4833 1416 draw_fuzzy(i);
4834 1416 advanceframe(true);
4835
4836
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1416 times.
1416 if(Quit)
4837 {
4838 break;
4839 }
4840 1416 }
4841 59 }
4842
4843 59 void zapin()
4844 {
4845 59 FFCore.warpScriptCheck();
4846 59 draw_screen(tmpscr);
4847 59 set_clip_rect(scrollbuf, 0, 0, scrollbuf->w, scrollbuf->h);
4848 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
4849 59 blit(framebuf,scrollbuf,0,0,256,0,256,224);
4850
4851 // zap out
4852 59 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4853
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 1416 times.
1475 for(int32_t i=24; i>=1; i--)
4854 {
4855 1416 draw_fuzzy(i);
4856 1416 advanceframe(true);
4857
4858
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1416 times.
1416 if(Quit)
4859 {
4860 break;
4861 }
4862 1416 }
4863 59 }
4864
4865
4866 23 void wavyout(bool showhero)
4867 {
4868 23 draw_screen(tmpscr, showhero);
4869 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
4870
4871 23 BITMAP *wavebuf = create_bitmap_ex(8,288,224);
4872 23 clear_to_color(wavebuf,0);
4873 23 blit(framebuf,wavebuf,0,0,16,0,256,224);
4874
4875 static PALETTE wavepal;
4876
4877 int32_t ofs;
4878 23 int32_t amplitude=8;
4879
4880 23 int32_t wavelength=4;
4881 23 double palpos=0, palstep=4, palstop=126;
4882
4883 23 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4884
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 966 times.
989 for(int32_t i=0; i<168; i+=wavelength)
4885 {
4886
2/2
✓ Branch 0 taken 247296 times.
✓ Branch 1 taken 966 times.
248262 for(int32_t l=0; l<256; l++)
4887 {
4888 247296 wavepal[l].r=vbound(int32_t(RAMpal[l].r+((palpos/palstop)*(63-RAMpal[l].r))),0,63);
4889 247296 wavepal[l].g=vbound(int32_t(RAMpal[l].g+((palpos/palstop)*(63-RAMpal[l].g))),0,63);
4890 247296 wavepal[l].b=vbound(int32_t(RAMpal[l].b+((palpos/palstop)*(63-RAMpal[l].b))),0,63);
4891 247296 }
4892
4893 966 palpos+=palstep;
4894
4895
1/2
✓ Branch 0 taken 966 times.
✗ Branch 1 not taken.
966 if(palpos>=0)
4896 {
4897 966 hw_palette = &wavepal;
4898 966 update_hw_pal = true;
4899 966 }
4900 else
4901 {
4902 hw_palette = &RAMpal;
4903 update_hw_pal = true;
4904 }
4905
4906
2/2
✓ Branch 0 taken 162288 times.
✓ Branch 1 taken 966 times.
163254 for(int32_t j=0; j+playing_field_offset<224; j++)
4907 {
4908
2/2
✓ Branch 0 taken 41545728 times.
✓ Branch 1 taken 162288 times.
41708016 for(int32_t k=0; k<256; k++)
4909 {
4910 41545728 ofs=0;
4911
4912
4/4
✓ Branch 0 taken 20278272 times.
✓ Branch 1 taken 21267456 times.
✓ Branch 2 taken 10139136 times.
✓ Branch 3 taken 10139136 times.
41545728 if((j<i)&&(j&1))
4913 {
4914 10139136 ofs=int32_t(zc::math::Sin((double(i+j)*2*PI/168.0))*amplitude);
4915 10139136 }
4916
4917 41545728 framebuf->line[j+playing_field_offset][k]=wavebuf->line[j+playing_field_offset][k+ofs+16];
4918 41545728 }
4919 162288 }
4920
4921 966 advanceframe(true);
4922
4923 // animate_combos();
4924
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 966 times.
966 if(Quit)
4925 break;
4926 966 }
4927
4928 23 destroy_bitmap(wavebuf);
4929 23 }
4930
4931 23 void wavyin()
4932 {
4933 23 draw_screen(tmpscr);
4934 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
4935
4936 23 BITMAP *wavebuf = create_bitmap_ex(8,288,224);
4937 23 clear_to_color(wavebuf,0);
4938 23 blit(framebuf,wavebuf,0,0,16,0,256,224);
4939
4940 static PALETTE wavepal;
4941
4942 //Breaks dark rooms.
4943 //In any case I don't think we need this, since palette is already loaded in doWarp() (famous last words...) -DD
4944 /*
4945 loadfullpal();
4946 loadlvlpal(DMaps[currdmap].color);
4947 ringcolor(false);
4948 */
4949 23 refreshpal=false;
4950 int32_t ofs;
4951 23 int32_t amplitude=8;
4952 23 int32_t wavelength=4;
4953 23 double palpos=168, palstep=4, palstop=126;
4954
4955 23 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4956
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 966 times.
989 for(int32_t i=0; i<168; i+=wavelength)
4957 {
4958
2/2
✓ Branch 0 taken 247296 times.
✓ Branch 1 taken 966 times.
248262 for(int32_t l=0; l<256; l++)
4959 {
4960 247296 wavepal[l].r=vbound(int32_t(RAMpal[l].r+((palpos/palstop)*(63-RAMpal[l].r))),0,63);
4961 247296 wavepal[l].g=vbound(int32_t(RAMpal[l].g+((palpos/palstop)*(63-RAMpal[l].g))),0,63);
4962 247296 wavepal[l].b=vbound(int32_t(RAMpal[l].b+((palpos/palstop)*(63-RAMpal[l].b))),0,63);
4963 247296 }
4964
4965 966 palpos-=palstep;
4966
4967
1/2
✓ Branch 0 taken 966 times.
✗ Branch 1 not taken.
966 if(palpos>=0)
4968 {
4969 966 hw_palette = &wavepal;
4970 966 update_hw_pal = true;
4971 966 }
4972 else
4973 {
4974 hw_palette = &RAMpal;
4975 update_hw_pal = true;
4976 }
4977
4978
2/2
✓ Branch 0 taken 162288 times.
✓ Branch 1 taken 966 times.
163254 for(int32_t j=0; j+playing_field_offset<224; j++)
4979 {
4980
2/2
✓ Branch 0 taken 41545728 times.
✓ Branch 1 taken 162288 times.
41708016 for(int32_t k=0; k<256; k++)
4981 {
4982 41545728 ofs=0;
4983
4984
4/4
✓ Branch 0 taken 21020160 times.
✓ Branch 1 taken 20525568 times.
✓ Branch 2 taken 10633728 times.
✓ Branch 3 taken 10386432 times.
41545728 if((j<(167-i))&&(j&1))
4985 {
4986 10386432 ofs=int32_t(zc::math::Sin((double(i+j)*2*PI/168.0))*amplitude);
4987 10386432 }
4988
4989 41545728 framebuf->line[j+playing_field_offset][k]=wavebuf->line[j+playing_field_offset][k+ofs+16];
4990 41545728 }
4991 162288 }
4992
4993 966 advanceframe(true);
4994 // animate_combos();
4995
4996
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 966 times.
966 if(Quit)
4997 break;
4998 966 }
4999
5000 23 destroy_bitmap(wavebuf);
5001 23 }
5002
5003 1619 void blackscr(int32_t fcnt,bool showsubscr)
5004 {
5005 1619 reset_pal_cycling();
5006 1619 script_drawing_commands.Clear();
5007
5008 1619 FFCore.warpScriptCheck();
5009 1619 bool showtime = game->should_show_time();
5010
2/2
✓ Branch 0 taken 1619 times.
✓ Branch 1 taken 48500 times.
50119 while(fcnt>0)
5011 {
5012 48500 clear_bitmap(framebuf);
5013
5014
2/2
✓ Branch 0 taken 13500 times.
✓ Branch 1 taken 35000 times.
48500 if(showsubscr)
5015 {
5016 35000 put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,showtime,sspUP);
5017
3/4
✓ Branch 0 taken 35000 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 750 times.
✓ Branch 3 taken 34250 times.
35000 if(get_bit(quest_rules, qr_SCRIPTDRAWSINWARPS) || (get_bit(quest_rules, qr_PASSIVE_SUBSCRIPT_RUNS_WHEN_GAME_IS_FROZEN)))
5018 {
5019 750 do_script_draws(framebuf, tmpscr, 0, playing_field_offset);
5020 750 }
5021 35000 }
5022
5023 48500 advanceframe(true);
5024
5025
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48500 times.
48500 if(Quit)
5026 break;
5027
5028 48500 --fcnt;
5029 }
5030 1619 }
5031
5032 563 void openscreen(int32_t shape)
5033 {
5034 563 reset_pal_cycling();
5035 563 black_opening_count=0;
5036
5037
3/4
✓ Branch 0 taken 98 times.
✓ Branch 1 taken 465 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 98 times.
563 if(COOLSCROLL || shape>-1)
5038 {
5039 465 open_black_opening(HeroX()+8, (HeroY()-HeroZ()-HeroFakeZ())+8+playing_field_offset, true, shape);
5040 465 return;
5041 }
5042 else
5043 {
5044 98 Hero.setDontDraw(true);
5045 98 show_subscreen_dmap_dots=false;
5046 98 show_subscreen_numbers=false;
5047 // show_subscreen_items=false;
5048 98 show_subscreen_life=false;
5049 }
5050
5051 98 int32_t x=128;
5052
5053 98 FFCore.warpScriptCheck();
5054
2/2
✓ Branch 0 taken 98 times.
✓ Branch 1 taken 7840 times.
7938 for(int32_t i=0; i<80; i++)
5055 {
5056 7840 draw_screen(tmpscr);
5057 //? draw_screen already draws the subscreen -DD
5058 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
5059 7840 x=128-(((i*128/80)/8)*8);
5060
5061
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7840 times.
7840 if(x>0)
5062 {
5063 7840 rectfill(framebuf,0,playing_field_offset,x,167+playing_field_offset,0);
5064 7840 rectfill(framebuf,256-x,playing_field_offset,255,167+playing_field_offset,0);
5065 7840 }
5066
5067 7840 advanceframe(true);
5068
5069
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7840 times.
7840 if(Quit)
5070 {
5071 break;
5072 }
5073 7840 }
5074
5075 98 Hero.setDontDraw(false);
5076 98 show_subscreen_items=true;
5077 98 show_subscreen_dmap_dots=true;
5078 563 }
5079
5080 void closescreen(int32_t shape)
5081 {
5082 reset_pal_cycling();
5083 black_opening_count=0;
5084
5085 if(COOLSCROLL || shape>-1)
5086 {
5087 close_black_opening(HeroX()+8, (HeroY()-HeroZ()-HeroFakeZ())+8+playing_field_offset, true, shape);
5088 return;
5089 }
5090 else
5091 {
5092 Hero.setDontDraw(true);
5093 show_subscreen_dmap_dots=false;
5094 show_subscreen_numbers=false;
5095 // show_subscreen_items=false;
5096 show_subscreen_life=false;
5097 }
5098
5099 int32_t x=128;
5100
5101 FFCore.warpScriptCheck();
5102 for(int32_t i=79; i>=0; --i)
5103 {
5104 draw_screen(tmpscr);
5105 //? draw_screen already draws the subscreen -DD
5106 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
5107 x=128-(((i*128/80)/8)*8);
5108
5109 if(x>0)
5110 {
5111 rectfill(framebuf,0,playing_field_offset,x,167+playing_field_offset,0);
5112 rectfill(framebuf,256-x,playing_field_offset,255,167+playing_field_offset,0);
5113 }
5114
5115 advanceframe(true);
5116
5117 if(Quit)
5118 {
5119 break;
5120 }
5121 }
5122
5123 Hero.setDontDraw(false);
5124 show_subscreen_items=true;
5125 show_subscreen_dmap_dots=true;
5126 }
5127
5128 122 int32_t TriforceCount()
5129 {
5130 122 int32_t c=0;
5131
5132
2/2
✓ Branch 0 taken 976 times.
✓ Branch 1 taken 122 times.
1098 for(int32_t i=1; i<=8; i++)
5133
2/2
✓ Branch 0 taken 326 times.
✓ Branch 1 taken 650 times.
1626 if(game->lvlitems[i]&liTRIFORCE)
5134 650 ++c;
5135
5136 122 return c;
5137 }
5138
5139 int32_t onCustomGame()
5140 {
5141 int32_t file = getsaveslot();
5142
5143 if(file < 0)
5144 return D_O_K;
5145
5146 bool ret = (custom_game(file)!=0);
5147 return ret ? D_CLOSE : D_O_K;
5148 }
5149
5150 int32_t onContinue()
5151 {
5152 return D_CLOSE;
5153 }
5154
5155 int32_t onEsc() // Unused?? -L
5156 {
5157 return zc_getrawkey(KEY_ESC, true)?D_CLOSE:D_O_K;
5158 }
5159
5160 int32_t onVsync()
5161 {
5162 Throttlefps = !Throttlefps;
5163 zc_set_config(cfg_sect,"throttlefps", (int32_t)Throttlefps);
5164 return D_O_K;
5165 }
5166
5167 int32_t onWinPosSave()
5168 {
5169 SaveWinPos = !SaveWinPos;
5170 zc_set_config(cfg_sect,"save_window_position",(int32_t)SaveWinPos);
5171 return D_O_K;
5172 }
5173
5174 int32_t onClickToFreeze()
5175 {
5176 ClickToFreeze = !ClickToFreeze;
5177 zc_set_config(cfg_sect,"clicktofreeze", (int32_t)ClickToFreeze);
5178 return D_O_K;
5179 }
5180
5181 int32_t OnSaveZCConfig()
5182 {
5183 if(jwin_alert3(
5184 "Save Configuration",
5185 "Are you sure that you wish to save your present configuration settings?",
5186 "This will overwrite your prior settings!",
5187 NULL,
5188 "&Yes",
5189 "&No",
5190 NULL,
5191 'y',
5192 'n',
5193 0,
5194 lfont) == 1)
5195 {
5196 save_game_configs();
5197 return D_O_K;
5198 }
5199 else return D_O_K;
5200 }
5201
5202 int32_t OnnClearQuestDir()
5203 {
5204 if(jwin_alert3(
5205 "Clear Current Directory Cache",
5206 "Are you sure that you wish to clear the current cached directory?",
5207 "This will default the current directory to the ROOT for this instance of ZC Player!",
5208 NULL,
5209 "&Yes",
5210 "&No",
5211 NULL,
5212 'y',
5213 'n',
5214 0,
5215 lfont) == 1)
5216 {
5217 zc_set_config("zeldadx","win_qst_dir","");
5218 flush_config_file();
5219 strcpy(qstdir,"");
5220 #ifdef __EMSCRIPTEN__
5221 em_sync_fs();
5222 #endif
5223 return D_O_K;
5224 }
5225 else return D_O_K;
5226 }
5227
5228
5229 int32_t onConsoleZASM()
5230 {
5231 if ( !zasm_debugger )
5232 {
5233 AlertDialog("WARNING: ZASM Debugger",
5234 "Enabling this will open the ZASM Debugger Console"
5235 "\nThis will likely grind ZC to a halt with lag."
5236 "\nTo make any use of this, it is suggested that you read"
5237 "\nthe documentation for 'void Breakpoint(char[] string);'"
5238 " in 'ZScript_Additions.txt'"
5239 "\nThis is not recommended for normal users,"
5240 " and is only intended for ZC developers,"
5241 "\nor quest developers coding directly in ZASM"
5242 "\nAre you sure that you wish to open the ZASM Debugger?",
5243 [&](bool ret,bool)
5244 {
5245 if(ret)
5246 {
5247 FFCore.ZASMPrint(true);
5248 }
5249 }).show();
5250 return D_O_K;
5251 }
5252 else
5253 {
5254 FFCore.ZASMPrint(false);
5255 return D_O_K;
5256 }
5257 }
5258
5259
5260 int32_t onConsoleZScript()
5261 {
5262 if ( !zscript_debugger )
5263 {
5264 AlertDialog("ZScript Debugger",
5265 "Enabling this will open the ZScript Debugger Console"
5266 "\nThis will display any messages logged by scripts,"
5267 " including script errors."
5268 "\nAre you sure that you wish to open the ZScript Debugger?",
5269 [&](bool ret,bool)
5270 {
5271 if(ret)
5272 {
5273 FFCore.ZScriptConsole(true);
5274 }
5275 }).show();
5276 return D_O_K;
5277 }
5278 else
5279 {
5280 FFCore.ZScriptConsole(false);
5281 return D_O_K;
5282 }
5283 }
5284
5285 int32_t onClrConsoleOnReload()
5286 {
5287 clearConsoleOnReload = !clearConsoleOnReload;
5288 zc_set_config("CONSOLE","clear_console_on_reload",clearConsoleOnReload?1:0);
5289 return D_O_K;
5290 }
5291 int32_t onClrConsoleOnLoad()
5292 {
5293 clearConsoleOnLoad = !clearConsoleOnLoad;
5294 zc_set_config("CONSOLE","clear_console_on_load",clearConsoleOnLoad?1:0);
5295 return D_O_K;
5296 }
5297
5298
5299 int32_t onFrameSkip()
5300 {
5301 FrameSkip = !FrameSkip;
5302 return D_O_K;
5303 }
5304
5305 int32_t onSaveDragResize()
5306 {
5307 SaveDragResize = !SaveDragResize;
5308 zc_set_config(cfg_sect,"save_drag_resize",(int32_t)SaveDragResize);
5309 return D_O_K;
5310 }
5311
5312 int32_t onDragAspect()
5313 {
5314 DragAspect = !DragAspect;
5315 zc_set_config(cfg_sect,"drag_aspect",(int32_t)DragAspect);
5316 return D_O_K;
5317 }
5318
5319 int32_t onTransLayers()
5320 {
5321 TransLayers = !TransLayers;
5322 zc_set_config(cfg_sect,"translayers",(int32_t)TransLayers);
5323 return D_O_K;
5324 }
5325
5326 int32_t onNESquit()
5327 {
5328 NESquit = !NESquit;
5329 zc_set_config(cfg_sect,"fastquit",(int32_t)NESquit);
5330 return D_O_K;
5331 }
5332
5333 int32_t onVolKeys()
5334 {
5335 volkeys = !volkeys;
5336 zc_set_config(sfx_sect,"volkeys",(int32_t)volkeys);
5337 return D_O_K;
5338 }
5339
5340 int32_t onShowFPS()
5341 {
5342 ShowFPS = !ShowFPS;
5343 zc_set_config(cfg_sect,"showfps",(int32_t)ShowFPS);
5344 return D_O_K;
5345 }
5346
5347 768252452 bool is_Fkey(int32_t k)
5348 {
5349
2/2
✓ Branch 0 taken 78127368 times.
✓ Branch 1 taken 690125084 times.
768252452 switch(k)
5350 {
5351 case KEY_F1:
5352 case KEY_F2:
5353 case KEY_F3:
5354 case KEY_F4:
5355 case KEY_F5:
5356 case KEY_F6:
5357 case KEY_F7:
5358 case KEY_F8:
5359 case KEY_F9:
5360 case KEY_F10:
5361 case KEY_F11:
5362 case KEY_F12:
5363 78127368 return true;
5364 }
5365
5366 690125084 return false;
5367 768252452 }
5368
5369 void kb_getkey(DIALOG *d);
5370
5371 //Used by all keyboard key settings dialogues.
5372 void kb_clearjoystick(DIALOG *d)
5373 {
5374 d->flags|=D_SELECTED;
5375
5376 scare_mouse();
5377 jwin_button_proc(MSG_DRAW,d,0);
5378 jwin_draw_win(gui_bmp, (gui_bmp->w-160)/2, (gui_bmp->h-48)/2, 168, 48, FR_WIN);
5379 // text_mode(vc(11));
5380 textout_centre_ex(gui_bmp, font, "Press any key to clear", gui_bmp->w/2, gui_bmp->h/2 - 8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5381 textout_centre_ex(gui_bmp, font, "ESC to cancel", gui_bmp->w/2, gui_bmp->h/2, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5382 unscare_mouse();
5383
5384 update_hw_screen(true);
5385
5386 clear_keybuf();
5387 int32_t k = next_press_key();
5388 clear_keybuf();
5389
5390 //shnarf
5391 //47=f1
5392 //59=esc
5393 // if(k>0 && k<123 && !((k>46)&&(k<60)))
5394 // *((int32_t*)d->dp3) = k;
5395 if ( k != 59 ) *((int32_t*)d->dp3) = 0;
5396
5397
5398 d->flags&=~D_SELECTED;
5399 }
5400
5401 //Clears key to 0.
5402 //Used by all keyboard key settings dialogues.
5403 void kb_clearkey(DIALOG *d);
5404
5405 int32_t d_j_clearbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5406 {
5407 switch(msg)
5408 {
5409 case MSG_KEY:
5410 case MSG_CLICK:
5411
5412 kb_clearjoystick(d);
5413
5414 while(gui_mouse_b())
5415 {
5416 clear_keybuf();
5417 rest(1);
5418 }
5419
5420 return D_REDRAW;
5421 }
5422
5423 return jwin_button_proc(msg,d,c);
5424 }
5425
5426 int32_t d_kbutton_proc(int32_t msg,DIALOG *d,int32_t c);
5427 //Only used in keyboard settings dialogues to clear keys.
5428 int32_t d_k_clearbutton_proc(int32_t msg,DIALOG *d,int32_t c);
5429
5430 void j_getbtn(DIALOG *d)
5431 {
5432 d->flags|=D_SELECTED;
5433 scare_mouse();
5434 jwin_button_proc(MSG_DRAW,d,0);
5435 jwin_draw_win(gui_bmp, (gui_bmp->w-160)/2, (gui_bmp->h-48)/2, 160, 48, FR_WIN);
5436 // text_mode(vc(11));
5437 int32_t y = gui_bmp->h/2 - 12;
5438 textout_centre_ex(gui_bmp, font, "Press a button", gui_bmp->w/2, y, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5439 textout_centre_ex(gui_bmp, font, "ESC to cancel", gui_bmp->w/2, y+8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5440 textout_centre_ex(gui_bmp, font, "SPACE to disable", gui_bmp->w/2, y+16, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5441 unscare_mouse();
5442
5443 update_hw_screen(true);
5444
5445 int32_t b = next_press_btn();
5446
5447 if(b>=0)
5448 *((int32_t*)d->dp3) = b;
5449
5450 d->flags&=~D_SELECTED;
5451
5452 if (player)
5453 player->joy_on = TRUE;
5454 }
5455
5456 int32_t d_jbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5457 {
5458 switch(msg)
5459 {
5460 case MSG_KEY:
5461 case MSG_CLICK:
5462
5463 j_getbtn(d);
5464
5465 while(gui_mouse_b()) {
5466 rest(1);
5467 clear_keybuf();
5468 }
5469
5470 return D_REDRAW;
5471 }
5472
5473 return jwin_button_proc(msg,d,c);
5474 }
5475
5476 //shnarf
5477 extern const char *key_str[];
5478 std::string get_keystr(int key);
5479
5480 const char *pan_str[4] = { "MONO", " 1/2", " 3/4", "FULL" };
5481 //extern int32_t zcmusic_bufsz;
5482
5483 static char str_a[80],str_b[80],str_s[80],str_m[80],str_l[80],str_r[80],str_p[80],str_ex1[80],str_ex2[80],str_ex3[80],str_ex4[80],
5484 str_leftmod1[80],str_leftmod2[80],str_rightmod1[80],str_rightmod2[80], str_left[80], str_right[80], str_up[80], str_down[80];
5485
5486 int32_t d_stringloader(int32_t msg,DIALOG *d,int32_t c)
5487 {
5488 //these are here to bypass compiler warnings about unused arguments
5489 c=c;
5490
5491 if(msg==MSG_DRAW)
5492 {
5493 switch(d->w)
5494 {
5495 case 0:
5496 sprintf(str_a,"%03d\n%s",Akey,key_str[Akey]);
5497 sprintf(str_b,"%03d\n%s",Bkey,key_str[Bkey]);
5498 sprintf(str_s,"%03d\n%s",Skey,key_str[Skey]);
5499 sprintf(str_l,"%03d\n%s",Lkey,key_str[Lkey]);
5500 sprintf(str_r,"%03d\n%s",Rkey,key_str[Rkey]);
5501 sprintf(str_p,"%03d\n%s",Pkey,key_str[Pkey]);
5502 sprintf(str_ex1,"%03d\n%s",Exkey1,key_str[Exkey1]);
5503 sprintf(str_ex2,"%03d\n%s",Exkey2,key_str[Exkey2]);
5504 sprintf(str_ex3,"%03d\n%s",Exkey3,key_str[Exkey3]);
5505 sprintf(str_ex4,"%03d\n%s",Exkey4,key_str[Exkey4]);
5506 sprintf(str_up,"%03d\n%s",DUkey,key_str[DUkey]);
5507 sprintf(str_down,"%03d\n%s",DDkey,key_str[DDkey]);
5508 sprintf(str_left,"%03d\n%s",DLkey,key_str[DLkey]);
5509 sprintf(str_right,"%03d\n%s",DRkey,key_str[DRkey]);
5510 sprintf(str_leftmod1,"%03d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5511 sprintf(str_leftmod2,"%03d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5512 sprintf(str_rightmod1,"%03d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5513 sprintf(str_rightmod2,"%03d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5514 break;
5515
5516 case 1:
5517 sprintf(str_a,"%03d\n%s",Abtn,joybtn_name(Abtn));
5518 sprintf(str_b,"%03d\n%s",Bbtn,joybtn_name(Bbtn));
5519 sprintf(str_s,"%03d\n%s",Sbtn,joybtn_name(Sbtn));
5520 sprintf(str_l,"%03d\n%s",Lbtn,joybtn_name(Lbtn));
5521 sprintf(str_r,"%03d\n%s",Rbtn,joybtn_name(Rbtn));
5522 sprintf(str_m,"%03d\n%s",Mbtn,joybtn_name(Mbtn));
5523 sprintf(str_p,"%03d\n%s",Pbtn,joybtn_name(Pbtn));
5524 sprintf(str_ex1,"%03d\n%s",Exbtn1,joybtn_name(Exbtn1));
5525 sprintf(str_ex2,"%03d\n%s",Exbtn2,joybtn_name(Exbtn2));
5526 sprintf(str_ex3,"%03d\n%s",Exbtn3,joybtn_name(Exbtn3));
5527 sprintf(str_ex4,"%03d\n%s",Exbtn4,joybtn_name(Exbtn4));
5528 sprintf(str_up,"%03d\n%s",DUbtn,joybtn_name(DUbtn));
5529 sprintf(str_down,"%03d\n%s",DDbtn,joybtn_name(DDbtn));
5530 sprintf(str_left,"%03d\n%s",DLbtn,joybtn_name(DLbtn));
5531 sprintf(str_right,"%03d\n%s",DRbtn,joybtn_name(DRbtn));
5532 sprintf(str_leftmod1,"%03d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5533 sprintf(str_leftmod2,"%03d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5534 sprintf(str_rightmod1,"%03d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5535 sprintf(str_rightmod2,"%03d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5536 break;
5537
5538 case 2:
5539 sprintf(str_a," %3d",midi_volume);
5540 sprintf(str_b," %3d",digi_volume);
5541 sprintf(str_l," %3d",emusic_volume);
5542 sprintf(str_m," %3dKB",zcmusic_bufsz);
5543 sprintf(str_r," %3d",sfx_volume);
5544 strcpy(str_s,pan_str[pan_style]);
5545 sprintf(str_leftmod1,"%3d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5546 sprintf(str_leftmod2,"%3d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5547 sprintf(str_rightmod1,"%3d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5548 sprintf(str_rightmod2,"%3d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5549 break;
5550 }
5551 }
5552
5553 return D_O_K;
5554 }
5555
5556 int32_t set_vol(void *dp3, int32_t d2)
5557 {
5558 switch(((int32_t*)dp3)[0])
5559 {
5560 case 0:
5561 midi_volume = zc_min(d2<<3,255);
5562 break;
5563
5564 case 1:
5565 digi_volume = zc_min(d2<<3,255);
5566 break;
5567
5568 case 2:
5569 emusic_volume = zc_min(d2<<3,255);
5570 break;
5571
5572 case 3:
5573 sfx_volume = zc_min(d2<<3,255);
5574 break;
5575 }
5576
5577 scare_mouse();
5578 // text_mode(vc(11));
5579 textprintf_right_ex(screen,lfont_l, ((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%3d",zc_min(d2<<3,255));
5580 unscare_mouse();
5581 return D_O_K;
5582 }
5583
5584 int32_t set_pan(void *dp3, int32_t d2)
5585 {
5586 pan_style = vbound(d2,0,3);
5587 scare_mouse();
5588 // text_mode(vc(11));
5589 textout_right_ex(screen,lfont_l, pan_str[pan_style],((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5590 unscare_mouse();
5591 return D_O_K;
5592 }
5593
5594 int32_t set_buf(void *dp3, int32_t d2)
5595 {
5596 scare_mouse();
5597 // text_mode(vc(11));
5598 zcmusic_bufsz = d2 + 1;
5599 textprintf_right_ex(screen,lfont_l, ((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%3dKB",zcmusic_bufsz);
5600 unscare_mouse();
5601 return D_O_K;
5602 }
5603
5604 static int32_t gamepad_btn_list[] =
5605 {
5606 6,
5607 7,8,9,10,11,12,13,14,15,16,17,
5608 18,19,20,21,22,23,24,25,26,27,28,
5609 29,30,31,32,33,34,35,36,37,38,39,
5610 -1
5611 };
5612
5613 static int32_t gamepad_dirs_list[] =
5614 {
5615 40,41,42,43,
5616 44,45,46,47,
5617 48,49,50,51,
5618 52,53,54,55,
5619 56,
5620 -1
5621 };
5622
5623 static TABPANEL gamepad_tabs[] =
5624 {
5625 // (text)
5626 { (char *)"Buttons", D_SELECTED, gamepad_btn_list, 0, NULL },
5627 { (char *)"Directions", 0, gamepad_dirs_list, 0, NULL },
5628 { NULL, 0, NULL, 0, NULL }
5629 };
5630
5631 static DIALOG gamepad_dlg[] =
5632 {
5633 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5634 { jwin_win_proc, 8, 24, 304, 256, 0, 0, 0, D_EXIT, 0, 0, (void *) "Gamepad Controls", NULL, NULL },
5635 { jwin_tab_proc, 8+4, 24+23,304-8,256-52,vc(0), vc(15), 0, 0, 0, 0, (void *) gamepad_tabs, NULL, (void *)gamepad_dlg },
5636 { d_stringloader, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5637 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5638 { jwin_button_proc, 90, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5639 { jwin_button_proc, 170, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5640 // 6
5641 { d_dummy_proc, 14, 61, 294, 192, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5642 // 7
5643 { jwin_ctext_proc, 92, 92-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5644 { jwin_ctext_proc, 92, 120-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_b, NULL, NULL },
5645 { jwin_ctext_proc, 92, 148-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5646 { jwin_ctext_proc, 92, 180-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex1, NULL, NULL },
5647 { jwin_ctext_proc, 92, 212-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex3, NULL, NULL },
5648 { jwin_ctext_proc, 237, 92-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_l, NULL, NULL },
5649 { jwin_ctext_proc, 237, 120-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_r, NULL, NULL },
5650 { jwin_ctext_proc, 237, 148-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_p, NULL, NULL },
5651 { jwin_ctext_proc, 237, 180-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex2, NULL, NULL },
5652 { jwin_ctext_proc, 237, 212-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex4, NULL, NULL },
5653 { jwin_ctext_proc, 92, 244-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_m, NULL, NULL },
5654 // 18
5655 { d_jbutton_proc, 22, 90-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "A", NULL, &Abtn},
5656 { d_jbutton_proc, 22, 118-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "B", NULL, &Bbtn},
5657 { d_jbutton_proc, 22, 146-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Start", NULL, &Sbtn},
5658 { d_jbutton_proc, 22, 178-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "X (EX1)", NULL, &Exbtn1},
5659 { d_jbutton_proc, 22, 210-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX3", NULL, &Exbtn3},
5660 { d_jbutton_proc, 167, 90-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "L", NULL, &Lbtn},
5661 { d_jbutton_proc, 167, 118-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "R", NULL, &Rbtn},
5662 { d_jbutton_proc, 167, 146-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Map", NULL, &Pbtn},
5663 { d_jbutton_proc, 167, 178-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Y (EX2)", NULL, &Exbtn2},
5664 { d_jbutton_proc, 167, 210-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX4", NULL, &Exbtn4},
5665 { d_jbutton_proc, 22, 242-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Menu", NULL, &Mbtn},
5666 // 29
5667 { d_j_clearbutton_proc, 22+91, 90-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Abtn},
5668 { d_j_clearbutton_proc, 22+91, 118-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Bbtn},
5669 { d_j_clearbutton_proc, 22+91, 146-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Sbtn},
5670 { d_j_clearbutton_proc, 22+91, 178-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn1},
5671 { d_j_clearbutton_proc, 22+91, 210-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn3},
5672 { d_j_clearbutton_proc, 167+91, 90-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Lbtn},
5673 { d_j_clearbutton_proc, 167+91, 118-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Rbtn},
5674 { d_j_clearbutton_proc, 167+91, 146-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Pbtn},
5675 { d_j_clearbutton_proc, 167+91, 178-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn2},
5676 { d_j_clearbutton_proc, 167+91, 210-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn4},
5677 { d_j_clearbutton_proc, 22+91, 242-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Mbtn},
5678 // 40
5679 { jwin_frame_proc, 14, 62, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5680 { jwin_frame_proc, 159, 62, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5681 { jwin_text_proc, 30, 68, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Vertical", NULL, NULL },
5682 { jwin_text_proc, 175, 68, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Horizontal", NULL, NULL },
5683 // 44
5684 { jwin_text_proc, 92, 84, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_up, NULL, NULL },
5685 { jwin_text_proc, 92, 112, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_down, NULL, NULL },
5686 { jwin_text_proc, 237, 84, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_left, NULL, NULL },
5687 { jwin_text_proc, 237, 112, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_right, NULL, NULL },
5688 // 48
5689 { d_jbutton_proc, 22, 82, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Up", NULL, &DUbtn },
5690 { d_jbutton_proc, 22, 110, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Down", NULL, &DDbtn },
5691 { d_jbutton_proc, 167, 82, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Left", NULL, &DLbtn },
5692 { d_jbutton_proc, 167, 110, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Right", NULL, &DRbtn },
5693 // 52
5694 { d_j_clearbutton_proc, 22+91, 82, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DUbtn},
5695 { d_j_clearbutton_proc, 22+91, 110, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DDbtn},
5696 { d_j_clearbutton_proc, 167+91, 82, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DLbtn},
5697 { d_j_clearbutton_proc, 167+91, 110, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DRbtn},
5698 // 56
5699 { jwin_check_proc, 22, 150, 147, 8, vc(14), vc(1), 0, 0, 1, 0, (void *) "Use Analog Stick/DPad", NULL, NULL },
5700 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5701 };
5702
5703 static int32_t keyboard_keys_list[] =
5704 {
5705 6,7,8,9,10,
5706 11,12,13,14,15,16,17,18,19,20,
5707 21,22,23,24,25,26,27,28,29,30,
5708 31,32,33,34,35,36,37,38,39,40,
5709 -1
5710 };
5711
5712 static int32_t keyboard_dirs_list[] =
5713 {
5714 41,42,43,44,
5715 45,46,47,48,
5716 49,50,51,52,
5717 53,54,55,56,
5718 -1
5719 };
5720
5721 static int32_t keyboard_mods_list[] =
5722 {
5723 57,58,59,60,
5724 61,62,63,64,
5725 65,66,67,68,
5726 69,70,71,72,
5727 -1
5728 };
5729
5730 static TABPANEL keyboard_control_tabs[] =
5731 {
5732 // (text)
5733 { (char *)"Keys", D_SELECTED, keyboard_keys_list, 0, NULL },
5734 { (char *)"Directions", 0, keyboard_dirs_list, 0, NULL },
5735 { (char *)"Cheat Mods", 0, keyboard_mods_list, 0, NULL },
5736 { NULL, 0, NULL, 0, NULL }
5737 };
5738
5739 static DIALOG keyboard_control_dlg[] =
5740 {
5741 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5742 { jwin_win_proc, 8, 39, 304, 240, 0, 0, 0, D_EXIT, 0, 0, (void *) "Keyboard Controls", NULL, NULL },
5743 { jwin_tab_proc, 8+4, 39+23,304-8,240-56,vc(0), vc(15), 0, 0, 0, 0, (void *) keyboard_control_tabs, NULL, (void *)keyboard_control_dlg },
5744 { d_stringloader, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5745 { jwin_button_proc, 90, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5746 { jwin_button_proc, 170, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5747 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5748 // Keys
5749 // 6
5750 { jwin_frame_proc, 14, 80, 148, 105, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5751 { jwin_frame_proc, 158, 80, 148, 105, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5752 { jwin_frame_proc, 14, 181, 292, 67, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5753 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Standard", NULL, NULL },
5754 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Extended", NULL, NULL },
5755 // 11
5756 { jwin_text_proc, 92-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5757 { jwin_text_proc, 92-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_b, NULL, NULL },
5758 { jwin_text_proc, 92-4, 158, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5759 { jwin_text_proc, 92-4, 190, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex1, NULL, NULL },
5760 { jwin_text_proc, 92-4, 222, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex3, NULL, NULL },
5761 { jwin_text_proc, 237-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_l, NULL, NULL },
5762 { jwin_text_proc, 237-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_r, NULL, NULL },
5763 { jwin_text_proc, 237-4, 158, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_p, NULL, NULL },
5764 { jwin_text_proc, 237-4, 190, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex2, NULL, NULL },
5765 { jwin_text_proc, 237-4, 222, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex4, NULL, NULL },
5766 // 21
5767 { d_kbutton_proc, 22, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "A", NULL, &Akey},
5768 { d_kbutton_proc, 22, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "B", NULL, &Bkey},
5769 { d_kbutton_proc, 22, 156, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Start", NULL, &Skey},
5770 { d_kbutton_proc, 22, 188, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "X (EX1)", NULL, &Exkey1},
5771 { d_kbutton_proc, 22, 220, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX3", NULL, &Exkey3},
5772 { d_kbutton_proc, 167, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "L", NULL, &Lkey},
5773 { d_kbutton_proc, 167, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "R", NULL, &Rkey},
5774 { d_kbutton_proc, 167, 156, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Map", NULL, &Pkey},
5775 { d_kbutton_proc, 167, 188, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Y (EX2)", NULL, &Exkey2},
5776 { d_kbutton_proc, 167, 220, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX4", NULL, &Exkey4},
5777 // 31
5778 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Akey},
5779 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Bkey},
5780 { d_k_clearbutton_proc, 22+91, 156, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Skey},
5781 { d_k_clearbutton_proc, 22+91, 188, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey1},
5782 { d_k_clearbutton_proc, 22+91, 220, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey3},
5783 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Lkey},
5784 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Rkey},
5785 { d_k_clearbutton_proc, 167+91, 156, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Pkey},
5786 { d_k_clearbutton_proc, 167+91, 188, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey2},
5787 { d_k_clearbutton_proc, 167+91, 220, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey4},
5788 // Dirs
5789 // 41
5790 { jwin_frame_proc, 14, 80, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5791 { jwin_frame_proc, 159, 80, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5792 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Vertical", NULL, NULL },
5793 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Horizontal", NULL, NULL },
5794 // 45
5795 { jwin_text_proc, 92-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_up, NULL, NULL },
5796 { jwin_text_proc, 92-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_down, NULL, NULL },
5797 { jwin_text_proc, 237-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_left, NULL, NULL },
5798 { jwin_text_proc, 237-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_right, NULL, NULL },
5799 // 49
5800 { d_kbutton_proc, 22, 100, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Up", NULL, &DUkey},
5801 { d_kbutton_proc, 22, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Down", NULL, &DDkey},
5802 { d_kbutton_proc, 167, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Left", NULL, &DLkey},
5803 { d_kbutton_proc, 167, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Right", NULL, &DRkey},
5804 // 53
5805 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DUkey},
5806 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DDkey},
5807 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DLkey},
5808 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DRkey},
5809 // Mods
5810 // 57
5811 { jwin_frame_proc, 14, 80, 148, 140-58, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5812 { jwin_frame_proc, 158, 80, 148, 140-58, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5813 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Left", NULL, NULL },
5814 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Right", NULL, NULL },
5815 // 61
5816 { jwin_text_proc, 92-26, 101, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_leftmod1, NULL, NULL },
5817 { jwin_text_proc, 92-26, 129, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_rightmod1, NULL, NULL },
5818 { jwin_text_proc, 237-4-22,101, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_leftmod2, NULL, NULL },
5819 { jwin_text_proc, 237-4-22,129, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_rightmod2, NULL, NULL },
5820 // 65
5821 { d_kbutton_proc, 22, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Main", NULL, &cheat_modifier_keys[0]},
5822 { d_kbutton_proc, 22, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Second", NULL, &cheat_modifier_keys[2]},
5823 { d_kbutton_proc, 167, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Main", NULL, &cheat_modifier_keys[1]},
5824 { d_kbutton_proc, 167, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Second", NULL, &cheat_modifier_keys[3]},
5825 // 69
5826 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[0]},
5827 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[2]},
5828 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[1]},
5829 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[3]},
5830 // 73
5831 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5832 };
5833
5834 /*
5835 int32_t midi_dp[3] = {0,147,104};
5836 int32_t digi_dp[3] = {1,147,120};
5837 int32_t pan_dp[3] = {0,147,136};
5838 int32_t buf_dp[3] = {0,147,152};
5839 */
5840 int32_t midi_dp[3] = {0,0,0};
5841 int32_t digi_dp[3] = {1,0,0};
5842 int32_t emus_dp[3] = {2,0,0};
5843 int32_t buf_dp[3] = {0,0,0};
5844 int32_t sfx_dp[3] = {3,0,0};
5845 int32_t pan_dp[3] = {0,0,0};
5846
5847 static DIALOG sound_dlg[] =
5848 {
5849 //(dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5850 29 { jwin_win_proc, 0, 0, 320, 178, 0, 0, 0, D_EXIT, 0, 0, (void *) "Sound Settings", NULL, NULL },
5851 29 { d_stringloader, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5852 29 { jwin_button_proc, 58, 148, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5853 29 { jwin_button_proc, 138, 148, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5854 29 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5855 29 { jwin_frame_proc, 10, 28, 300, 112, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
5856 29 { jwin_rtext_proc, 190, 40, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_a, NULL, NULL },
5857 29 { jwin_rtext_proc, 190, 56, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_b, NULL, NULL },
5858 29 { jwin_rtext_proc, 190, 72, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_l, NULL, NULL },
5859 29 { jwin_rtext_proc, 190, 88, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_m, NULL, NULL },
5860 // 10
5861 29 { jwin_rtext_proc, 190, 104, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_r, NULL, NULL },
5862 29 { jwin_rtext_proc, 190, 120, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_s, NULL, NULL },
5863 29 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5864 29 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5865 29 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5866 29 { jwin_slider_proc, 196, 40, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, midi_dp },
5867 29 { jwin_slider_proc, 196, 56, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, digi_dp },
5868 29 { jwin_slider_proc, 196, 72, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, emus_dp },
5869 29 { jwin_slider_proc, 196, 88, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 127, 0, NULL, (void *) set_buf, buf_dp },
5870 29 { jwin_slider_proc, 196, 104, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, sfx_dp },
5871 //20
5872 29 { jwin_slider_proc, 196, 120, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 3, 0, NULL, (void *) set_pan, pan_dp },
5873 29 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5874 29 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5875 29 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5876 29 { jwin_text_proc, 17, 40, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Master MIDI Volume", NULL, NULL },
5877 29 { jwin_text_proc, 17, 56, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Master Digi Volume", NULL, NULL },
5878 29 { jwin_text_proc, 17, 72, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Enhanced Music Volume", NULL, NULL },
5879 29 { jwin_text_proc, 17, 88, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Enhanced Music Buffer", NULL, NULL },
5880 29 { jwin_text_proc, 17, 104, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "SFX Volume", NULL, NULL },
5881 29 { jwin_text_proc, 17, 120, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "SFX Pan", NULL, NULL },
5882 //30
5883 29 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5884 29 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5885 29 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5886 29 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5887 };
5888
5889 char zc_builddate[80];
5890 char zc_aboutstr[80];
5891
5892 static DIALOG about_dlg[] =
5893 {
5894 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
5895 { jwin_win_proc, 68, 52, 184, 154, 0, 0, 0, D_EXIT, 0, 0, (void *) "About", NULL, NULL },
5896 { jwin_button_proc, 140, 176, 41, 21, vc(14), 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5897 { jwin_ctext_proc, 160, 84, 0, 8, vc(0), vc(11), 0, 0, 0, 0, zc_aboutstr, NULL, NULL },
5898 { jwin_ctext_proc, 160, 92, 0, 8, vc(0) , vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5899 { jwin_ctext_proc, 160, 100, 0, 8, vc(0) , vc(11), 0, 0, 0, 0, zc_builddate, NULL, NULL },
5900 { jwin_text_proc, 88, 124, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Coded by:", NULL, NULL },
5901 { jwin_text_proc, 88, 132, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) " Phantom Menace", NULL, NULL },
5902 { jwin_text_proc, 88, 144, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Produced by:", NULL, NULL },
5903 { jwin_text_proc, 88, 152, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) " Armageddon Games", NULL, NULL },
5904 { jwin_frame_proc, 80, 117, 160, 50, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5905 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5906 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5907 };
5908
5909
5910 static DIALOG quest_dlg[] =
5911 {
5912 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
5913 { jwin_win_proc, 68, 25, 184, 190, 0, 0, 0, D_EXIT, 0, 0, (void *) "Quest Info", NULL, NULL },
5914 { jwin_edit_proc, 84, 54, 152, 16, 0, 0, 0, D_READONLY, 100, 0, NULL, NULL, NULL },
5915 { jwin_text_proc, 89, 84, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Number:", NULL, NULL },
5916 { jwin_text_proc, 152, 84, 24, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5917 { jwin_text_proc, 89, 94, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Version:", NULL, NULL },
5918 { jwin_text_proc, 160, 94, 64, 8, vc(7), vc(11), 0, 0, 0, 0, header_version_nul_term, NULL, NULL },
5919 { jwin_text_proc, 89, 104, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "ZQ Version:", NULL, NULL },
5920 { jwin_text_proc, 184, 104, 64, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5921 { jwin_text_proc, 84, 126, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Title:", NULL, NULL },
5922 { jwin_textbox_proc, 84, 136, 152, 24, 0, 0, 0, 0, 0, 0, QHeader.title, NULL, NULL },
5923 { jwin_text_proc, 84, 168, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Author:", NULL, NULL },
5924 { jwin_textbox_proc, 84, 178, 152, 24, 0, 0, 0, 0, 0, 0, QHeader.author, NULL, NULL },
5925 { jwin_frame_proc, 84, 79, 152, 38, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5926 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5927 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5928 };
5929
5930 static DIALOG triforce_dlg[] =
5931 {
5932 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
5933 { jwin_win_proc, 72, 64, 177, 105, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Triforce Pieces", NULL, NULL },
5934 // 1
5935 { jwin_check_proc, 129, 94, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "1", NULL, NULL },
5936 { jwin_check_proc, 129, 104, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "2", NULL, NULL },
5937 { jwin_check_proc, 129, 114, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "3", NULL, NULL },
5938 { jwin_check_proc, 129, 124, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "4", NULL, NULL },
5939 { jwin_check_proc, 172, 94, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "5", NULL, NULL },
5940 { jwin_check_proc, 172, 104, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "6", NULL, NULL },
5941 { jwin_check_proc, 172, 114, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "7", NULL, NULL },
5942 { jwin_check_proc, 172, 124, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "8", NULL, NULL },
5943 // 9
5944 { jwin_button_proc, 90, 144, 61, 21, vc(0), vc(11), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
5945 { jwin_button_proc, 170, 144, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5946 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5947 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5948 };
5949
5950 bool zc_getname(const char *prompt,const char *ext,EXT_LIST *list,const char *def,bool usefilename)
5951 {
5952 go();
5953 int32_t ret=0;
5954 ret = zc_getname_nogo(prompt,ext,list,def,usefilename);
5955 comeback();
5956 return ret != 0;
5957 }
5958
5959
5960 bool zc_getname_nogo(const char *prompt,const char *ext,EXT_LIST *list,const char *def,bool usefilename)
5961 {
5962 if(def!=modulepath)
5963 strcpy(modulepath,def);
5964
5965 if(!usefilename)
5966 {
5967 int32_t i=(int32_t)strlen(modulepath);
5968
5969 while(i>=0 && modulepath[i]!='\\' && modulepath[i]!='/')
5970 modulepath[i--]=0;
5971 }
5972
5973 // int32_t ret = file_select_ex(prompt,modulepath,ext,255,-1,-1);
5974 int32_t ret=0;
5975 int32_t sel=0;
5976
5977 if(list==NULL)
5978 {
5979 ret = jwin_file_select_ex(prompt,modulepath,ext,2048,-1,-1,lfont);
5980 }
5981 else
5982 {
5983 ret = jwin_file_browse_ex(prompt, modulepath, list, &sel, 2048, -1, -1, lfont);
5984 }
5985
5986 return ret!=0;
5987 }
5988
5989 //The Dialogue that loads a ZMOD Module File
5990 int32_t zc_load_zmod_module_file()
5991 {
5992 if ( Playing )
5993 {
5994 jwin_alert("Error","Cannot change module while playing a quest!",NULL,NULL,"O&K",NULL,'k',0,lfont);
5995 return -1;
5996 }
5997 if(!zc_getname("Load Module (.zmod)","zmod",NULL,modulepath,false))
5998 return D_CLOSE;
5999
6000 FILE *tempmodule = fopen(modulepath,"r");
6001
6002 if(tempmodule == NULL)
6003 {
6004 jwin_alert("Error","Cannot open specified file!",NULL,NULL,"O&K",NULL,'k',0,lfont);
6005 return -1;
6006 }
6007
6008
6009 //Set the module path:
6010 memset(moduledata.module_name, 0, sizeof(moduledata.module_name));
6011 strcpy(moduledata.module_name, modulepath);
6012 al_trace("New Module Path is: %s \n", moduledata.module_name);
6013 zc_set_config("ZCMODULE","current_module",moduledata.module_name);
6014 zcm.init(true); //Load the module values.
6015 moduledata.refresh_title_screen = 1;
6016 // refresh_select_screen = 1;
6017 build_biic_list();
6018 return D_O_K;
6019 }
6020
6021 static DIALOG module_info_dlg[] =
6022 {
6023 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
6024
6025
6026 { jwin_win_proc, 0, 0, 200, 200, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "About Current Module", NULL, NULL },
6027 //1
6028 { jwin_text_proc, 10, 20, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"Module:", NULL, NULL },
6029 //2
6030 { jwin_text_proc, 50, 20, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6031 { jwin_text_proc, 10, 30, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"Author:", NULL, NULL },
6032 //4
6033 { jwin_text_proc, 50, 30, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6034 { jwin_text_proc, 10, 40, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6035 { jwin_text_proc, 10, 50, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"Information:", NULL, NULL },
6036 //7
6037
6038 { jwin_text_proc, 10, 60, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6039 { jwin_text_proc, 10, 70, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6040 { jwin_text_proc, 10, 80, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6041 { jwin_text_proc, 10, 90, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6042 { jwin_text_proc, 10, 100, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6043 { jwin_text_proc, 10, 120, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6044 { jwin_text_proc, 10, 130, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6045 { jwin_text_proc, 10, 140, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6046 { jwin_text_proc, 10, 150, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6047
6048 { jwin_button_proc, 40, 160, 50, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6049 { jwin_button_proc, 200-40-50, 160, 50, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6050 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6051 };
6052
6053 void about_zcplayer_module(const char *prompt,int32_t initialval)
6054 {
6055
6056 module_info_dlg[0].dp2 = lfont;
6057 if ( moduledata.moduletitle[0] != 0 )
6058 module_info_dlg[2].dp = (char*)moduledata.moduletitle;
6059
6060 if ( moduledata.moduleauthor[0] != 0 )
6061 module_info_dlg[4].dp = (char*)moduledata.moduleauthor;
6062
6063 if ( moduledata.moduleinfo0[0] != 0 )
6064 module_info_dlg[7].dp = (char*)moduledata.moduleinfo0;
6065 if ( moduledata.moduleinfo1[0] != 0 )
6066 module_info_dlg[8].dp = (char*)moduledata.moduleinfo1;
6067 if ( moduledata.moduleinfo2[0] != 0 )
6068 module_info_dlg[9].dp = (char*)moduledata.moduleinfo2;
6069 if ( moduledata.moduleinfo3[0] != 0 )
6070 module_info_dlg[10].dp = (char*)moduledata.moduleinfo3;
6071 if ( moduledata.moduleinfo4[0] != 0 )
6072 module_info_dlg[11].dp = (char*)moduledata.moduleinfo4;
6073
6074 char module_date[255];
6075 memset(module_date, 0, sizeof(module_date));
6076 sprintf(module_date,"Build Date: %s %s, %d at @ %d:%d %s", dayextension(moduledata.modday).c_str(),
6077 (char*)months[moduledata.modmonth], moduledata.modyear, moduledata.modhour, moduledata.modminute, moduledata.moduletimezone);
6078
6079
6080
6081 char module_vers[255];
6082 memset(module_vers, 0, sizeof(module_vers));
6083 sprintf(module_vers, "Version: %d.%d.%d.%d", moduledata.modver_1, moduledata.modver_2, moduledata.modver_3, moduledata.modver_4);
6084
6085
6086 //sprintf(tilecount,"%d",1);
6087
6088 char module_build[255];
6089 memset(module_build, 0, sizeof(module_build));
6090 if ( moduledata.modbeta )
6091 sprintf(module_build,"Module Build: %d, %s: %d", moduledata.modbuild, (moduledata.modbeta<0) ? "Alpha" : "Beta", moduledata.modbeta );
6092 else
6093 sprintf(module_build,"Module Build: %d", moduledata.modbuild);
6094
6095 module_info_dlg[12].dp = (char*)module_date;
6096 module_info_dlg[13].dp = (char*)module_vers;
6097 module_info_dlg[14].dp = (char*)module_build;
6098
6099 large_dialog(module_info_dlg);
6100
6101 int32_t ret = zc_popup_dialog(module_info_dlg,-1);
6102 jwin_center_dialog(module_info_dlg);
6103
6104
6105 }
6106
6107 int32_t onAbout_ZCP_Module()
6108 {
6109 about_zcplayer_module("About Module (.zmod)", 0);
6110 return D_O_K;
6111 }
6112
6113 //New Modules Menu for 2.55+
6114 static MENU zcmodule_menu[] =
6115 {
6116 { (char *)"&Load Module...", zc_load_zmod_module_file, NULL, 0, NULL },
6117 { (char *)"&About Module", onAbout_ZCP_Module, NULL, 0, NULL },
6118
6119 { NULL, NULL, NULL, 0, NULL }
6120 };
6121
6122 int32_t onToggleRecordingNewSaves()
6123 {
6124 if (zc_get_config("zeldadx", "replay_new_saves", false))
6125 {
6126 zc_set_config("zeldadx", "replay_new_saves", false);
6127 }
6128 else
6129 {
6130 zc_set_config("zeldadx", "replay_new_saves", true);
6131 jwin_alert("Recording", "Newly created saves will be recorded and written to a replay file.",
6132 NULL,NULL,"OK",NULL,13,27,lfont);
6133 }
6134 return D_O_K;
6135 }
6136
6137 int32_t onToggleSnapshotAllFrames()
6138 {
6139 replay_set_snapshot_all_frames(!replay_is_snapshot_all_frames());
6140 return D_O_K;
6141 }
6142
6143 int32_t onStopReplayOrRecord()
6144 {
6145 if (replay_is_replaying())
6146 {
6147 replay_quit();
6148 }
6149 else if (replay_get_mode() == ReplayMode::Record)
6150 {
6151 if (!replay_get_meta_bool("test_mode"))
6152 {
6153 jwin_alert("Recording", "You cannot stop recording a save file.",
6154 NULL,NULL,"OK",NULL,13,27,lfont);
6155 return D_CLOSE;
6156 }
6157
6158 if (jwin_alert("Stop Recording",
6159 "Save replay to disk and stop recording?",
6160 "This will stop the recording.",
6161 NULL,
6162 "Yes","No",13,27,lfont) != 1)
6163 return D_CLOSE;
6164
6165 replay_save();
6166 replay_stop();
6167 }
6168 return D_O_K;
6169 }
6170
6171 static int32_t handle_on_load_replay(ReplayMode mode)
6172 {
6173 if (Playing)
6174 {
6175 if (jwin_alert("Replay - Warning!",
6176 "Loading a replay will exit the current game.",
6177 "All unsaved progress will be lost.",
6178 "Do you wish to continue?",
6179 "Yes","No",13,27,lfont) != 1)
6180 return D_CLOSE;
6181 }
6182
6183 std::string mode_string = replay_mode_to_string(mode);
6184 mode_string[0] = std::toupper(mode_string[0]);
6185
6186 std::string line_1 = "Select a replay file to play back.";
6187 std::string line_2 = "You won't be able to save, and it won't effect existing saves.";
6188 std::string line_3 = "You can stop the replay and take over manually any time.";
6189 if (mode == ReplayMode::Update)
6190 {
6191 line_1 = "Select a replay file to update.";
6192 line_2 = "WARNING: be sure to back up the zplay file";
6193 line_3 = "and verify that the updated replay works as expected!";
6194 }
6195
6196 if (jwin_alert(mode_string.c_str(),
6197 line_1.c_str(),
6198 line_2.c_str(),
6199 line_3.c_str(),
6200 "OK","Nevermind",13,27,lfont) == 1)
6201 {
6202 char replay_path[2048];
6203 strcpy(replay_path, "replays/");
6204 if (jwin_file_select_ex(
6205 fmt::format("Load Replay (.{})", REPLAY_EXTENSION).c_str(),
6206 replay_path, REPLAY_EXTENSION.c_str(), 2048, -1, -1, lfont) == 0)
6207 return D_CLOSE;
6208
6209 replay_quit();
6210 load_replay_file_deferred(mode, replay_path);
6211 Quit = qRESET;
6212 return D_CLOSE;
6213 }
6214 return D_O_K;
6215 }
6216
6217 int32_t onLoadReplay()
6218 {
6219 return handle_on_load_replay(ReplayMode::Replay);
6220 }
6221
6222 int32_t onLoadReplayAssert()
6223 {
6224 return handle_on_load_replay(ReplayMode::Assert);
6225 }
6226
6227 int32_t onLoadReplayUpdate()
6228 {
6229 return handle_on_load_replay(ReplayMode::Update);
6230 }
6231
6232 int32_t onSaveReplay()
6233 {
6234 if (replay_get_mode() == ReplayMode::Record)
6235 {
6236 if (!replay_get_meta_bool("test_mode"))
6237 {
6238 if (jwin_alert("Save Replay",
6239 "This will save a copy of the replay up to this point.",
6240 "The official replay file will be untouched.",
6241 "Do you wish to continue?",
6242 "Yes","No",13,27,lfont) != 1)
6243 return D_CLOSE;
6244
6245 char replay_path[2048];
6246 strcpy(replay_path, replay_get_replay_path().string().c_str());
6247 if (jwin_file_select_ex(
6248 fmt::format("Save Replay (.{})", REPLAY_EXTENSION).c_str(),
6249 replay_path, REPLAY_EXTENSION.c_str(), 2048, -1, -1, lfont) == 0)
6250 return D_CLOSE;
6251
6252 if (fileexists(replay_path))
6253 {
6254 jwin_alert("Save Replay", "You cannot overwrite an existing file.",
6255 NULL,NULL,"OK",NULL,13,27,lfont);
6256 return D_CLOSE;
6257 }
6258
6259 replay_save(replay_path);
6260 }
6261 else
6262 {
6263 replay_save();
6264 }
6265 }
6266 return D_O_K;
6267 }
6268
6269 static MENU replay_menu[] =
6270 {
6271 { (char *)"Record new saves", onToggleRecordingNewSaves, NULL, 0, NULL },
6272 { (char *)"Stop replay", onStopReplayOrRecord, NULL, 0, NULL },
6273 { (char *)"Load replay", onLoadReplay, NULL, 0, NULL },
6274 { (char *)"Load replay (assert)", onLoadReplayAssert, NULL, 0, NULL },
6275 { (char *)"Load replay (update)", onLoadReplayUpdate, NULL, 0, NULL },
6276 { (char *)"Save replay", onSaveReplay, NULL, 0, NULL },
6277 { (char *)"Enable snapshot all frames", onToggleSnapshotAllFrames,NULL, 0, NULL },
6278
6279 { NULL, NULL, NULL, 0, NULL }
6280 };
6281
6282 static DIALOG credits_dlg[] =
6283 {
6284 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6285 { jwin_win_proc, 40, 38, 241, 173, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Zelda Classic Credits", NULL, NULL },
6286 { jwin_frame_proc, 47, 65, 227, 115, vc(15), vc(1), 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
6287 { d_bitmap_proc, 49, 67, 222, 110, vc(15), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
6288 { jwin_button_proc, 140, 184, 41, 21, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6289 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6290 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6291 };
6292
6293 29 static ListData dmap_list(dmaplist, &font);
6294
6295 static DIALOG goto_dlg[] =
6296 {
6297 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6298 { jwin_win_proc, 48, 25, 205, 100, 0, 0, 0, D_EXIT, 0, 0, (void *) "Goto Location", NULL, NULL },
6299 { jwin_button_proc, 90, 176-78, 61, 21, vc(14), 0, 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6300 { jwin_button_proc, 170, 176-78, 61, 21, vc(14), 0, 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6301 { jwin_text_proc, 55, 129-75, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "DMap:", NULL, NULL },
6302 { jwin_droplist_proc, 88, 126-75, 160, 16, 0, 0, 0, 0, 0, 0, (void *) &dmap_list, NULL, NULL },
6303 { jwin_text_proc, 55, 149-75, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Screen:", NULL, NULL },
6304 { jwin_edit_proc, 132, 146-75, 91, 16, 0, 0, 0, 0, 2, 0, NULL, NULL, NULL },
6305 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6306 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6307 };
6308
6309 int32_t onGoTo()
6310 {
6311 bool music = false;
6312 music = music;
6313 sprintf(cheat_goto_screen_str,"%X",cheat_goto_screen);
6314
6315 goto_dlg[0].dp2=lfont;
6316 goto_dlg[4].d2=cheat_goto_dmap;
6317 goto_dlg[6].dp=cheat_goto_screen_str;
6318
6319 clear_keybuf();
6320
6321 large_dialog(goto_dlg);
6322
6323 if(zc_popup_dialog(goto_dlg,4)==1)
6324 {
6325 // dmap, screen
6326 cheats_enqueue(Cheat::GoTo, goto_dlg[4].d2, zc_min(zc_xtoi(cheat_goto_screen_str),0x7F));
6327 };
6328
6329 return D_O_K;
6330 }
6331
6332 int32_t onGoToComplete()
6333 {
6334 if(!Playing)
6335 {
6336 return D_O_K;
6337 }
6338
6339 system_pal();
6340 music_pause();
6341 pause_all_sfx();
6342 show_mouse(screen);
6343 onGoTo();
6344 eat_buttons();
6345
6346 zc_readrawkey(KEY_ESC);
6347
6348 show_mouse(NULL);
6349 game_pal();
6350 music_resume();
6351 resume_all_sfx();
6352 return D_O_K;
6353 }
6354
6355 int32_t onCredits()
6356 {
6357 go();
6358
6359 BITMAP *win = create_bitmap_ex(8,222,110);
6360
6361 if(!win)
6362 return D_O_K;
6363
6364 int32_t c=0;
6365 int32_t l=0;
6366 int32_t ol=-1;
6367 RLE_SPRITE *rle = (RLE_SPRITE*)(datafile[RLE_CREDITS].dat);
6368 RGB *pal = (RGB*)(datafile[PAL_CREDITS].dat);
6369 PALETTE tmppal;
6370
6371 rti_gui.transparency_index = 1;
6372
6373 clear_to_color(win, rti_gui.transparency_index);
6374 draw_rle_sprite(win,rle,0,0);
6375 credits_dlg[0].dp2=lfont;
6376 credits_dlg[1].fg = jwin_pal[jcDISABLED_FG];
6377 credits_dlg[2].dp = win;
6378
6379 set_palette_range(black_palette,0,127,false);
6380
6381 DIALOG_PLAYER *p = init_dialog(credits_dlg,3);
6382
6383 BITMAP* old_screen = screen;
6384 BITMAP* gui_bmp = zc_get_gui_bmp();
6385 ASSERT(gui_bmp);
6386 clear_to_color(gui_bmp, rti_gui.transparency_index);
6387 screen = gui_bmp;
6388
6389 while(update_dialog(p))
6390 {
6391 throttleFPS();
6392 ++c;
6393 l = zc_max((c>>1)-30,0);
6394
6395 if(l > rle->h)
6396 l = c = 0;
6397
6398 if(l > rle->h - 112)
6399 l = rle->h - 112;
6400
6401 clear_bitmap(win);
6402 draw_rle_sprite(win,rle,0,0-l);
6403
6404 if(c<=64)
6405 fade_interpolate(black_palette,pal,tmppal,c,0,127);
6406
6407 set_palette_range(tmppal,0,127,false);
6408
6409 if(l!=ol)
6410 {
6411 scare_mouse();
6412 d_bitmap_proc(MSG_DRAW,credits_dlg+2,0);
6413 unscare_mouse();
6414 SCRFIX();
6415 ol=l;
6416 }
6417
6418 update_hw_screen();
6419 }
6420
6421 screen = old_screen;
6422 system_pal();
6423
6424 shutdown_dialog(p);
6425 destroy_bitmap(win);
6426 //comeback();
6427
6428 rti_gui.transparency_index = 0;
6429
6430 return D_O_K;
6431 }
6432
6433 const char *midilist(int32_t index, int32_t *list_size)
6434 {
6435 if(index<0)
6436 {
6437 *list_size=0;
6438
6439 for(int32_t i=0; i<MAXMIDIS; i++)
6440 if(tunes[i].data)
6441 ++(*list_size);
6442
6443 return NULL;
6444 }
6445
6446 int32_t i=0,m=0;
6447
6448 while(m<=index && i<=MAXMIDIS)
6449 {
6450 if(tunes[i].data)
6451 ++m;
6452
6453 ++i;
6454 }
6455
6456 --i;
6457
6458 if(i==MAXMIDIS && m<index)
6459 return "(null)";
6460
6461 return tunes[i].title;
6462 }
6463
6464 /* ------- MIDI info stuff -------- */
6465
6466 char *text;
6467 midi_info *zmi;
6468 bool dialog_running;
6469 bool listening;
6470
6471 void get_info(int32_t index);
6472
6473 int32_t d_midilist_proc(int32_t msg,DIALOG *d,int32_t c)
6474 {
6475 int32_t d2 = d->d2;
6476 int32_t ret = jwin_droplist_proc(msg,d,c);
6477
6478 if(d2!=d->d2)
6479 {
6480 get_info(d->d2);
6481 }
6482
6483 return ret;
6484 }
6485
6486 int32_t d_listen_proc(int32_t msg,DIALOG *d,int32_t c)
6487 {
6488 /* 'd->d1' is offset from 'd' in DIALOG array to midilist proc */
6489
6490 int32_t ret = jwin_button_proc(msg,d,c);
6491
6492 if(ret == D_CLOSE)
6493 {
6494 // get current midi index
6495 int32_t index = (d+(d->d1))->d2;
6496 int32_t i=0, m=0;
6497
6498 while(m<=index && i<=MAXMIDIS)
6499 {
6500 if(tunes[i].data)
6501 ++m;
6502
6503 ++i;
6504 }
6505
6506 --i;
6507 jukebox(i);
6508 listening = true;
6509 ret = D_O_K;
6510 }
6511
6512 return ret;
6513 }
6514
6515 int32_t d_savemidi_proc(int32_t msg,DIALOG *d,int32_t c)
6516 {
6517 /* 'd->d1' is offset from 'd' in DIALOG array to midilist proc */
6518
6519 int32_t ret = jwin_button_proc(msg,d,c);
6520
6521 if(ret == D_CLOSE)
6522 {
6523 // get current midi index
6524 int32_t index = (d+(d->d1))->d2;
6525 int32_t i=0, m=0;
6526
6527 while(m<=index && i<=MAXMIDIS)
6528 {
6529 if(tunes[i].data)
6530 ++m;
6531
6532 ++i;
6533 }
6534
6535 --i;
6536
6537 // get file name
6538
6539 int32_t sel=0;
6540 //struct ffblk f;
6541 char title[40] = "Save MIDI: ";
6542 char fname[2048];
6543 memset(fname,0,2048);
6544 static EXT_LIST list[] =
6545 {
6546 { (char *)"MIDI files (*.mid)", (char *)"mid" },
6547 { (char *)"HTML files (*.html, *.html)", (char *)"htm html" },
6548 { NULL, NULL }
6549 };
6550
6551 strcpy(title+11, tunes[i].title);
6552 title[39] = '\0';
6553
6554 if(jwin_file_browse_ex(title, fname, list, &sel, 2048, -1, -1, lfont)==0)
6555 goto done;
6556
6557 if(exists(fname))
6558 {
6559 if(jwin_alert(title, fname, "already exists.", "Overwrite it?", "&Yes","&No",'y','n',lfont)==2)
6560 goto done;
6561 }
6562
6563 // save midi i
6564
6565 if(save_midi(fname, (MIDI*)tunes[i].data) != 0)
6566 jwin_alert(title, "Error saving MIDI to", fname, NULL, "Darn", NULL,13,27,lfont);
6567
6568 done:
6569 chop_path(fname);
6570 ret = D_REDRAW;
6571 }
6572
6573 return ret;
6574 }
6575
6576 29 static ListData midi_list(midilist, &font);
6577
6578 static DIALOG midi_dlg[] =
6579 {
6580 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6581 { jwin_win_proc, 8, 28, 304, 184, 0, 0, 0, D_EXIT, 0, 0, (void *) "MIDI Info", NULL, NULL },
6582 { jwin_text_proc, 32, 60, 40, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Tune:", NULL, NULL },
6583 { d_midilist_proc, 80, 56, 192, 16, 0, 0, 0, 0, 0, 0, (void *) &midi_list, NULL, NULL },
6584 { jwin_textbox_proc, 15, 80, 290, 96, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6585 { d_listen_proc, 24, 183, 72, 21, 0, 0, 'l', D_EXIT, -2, 0, (void *) "&Listen", NULL, NULL },
6586 { d_savemidi_proc, 108, 183, 72, 21, 0, 0, 's', D_EXIT, -3, 0, (void *) "&Save", NULL, NULL },
6587 { jwin_button_proc, 236, 183, 61, 21, 0, 0, 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
6588 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6589 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6590 };
6591
6592 void get_info(int32_t index)
6593 {
6594 int32_t i=0, m=0;
6595
6596 while(m<=index && i<=MAXMIDIS)
6597 {
6598 if(tunes[i].data)
6599 ++m;
6600
6601 ++i;
6602 }
6603
6604 --i;
6605
6606 if(i==MAXMIDIS && m<index)
6607 strcpy(text,"(null)");
6608 else
6609 {
6610 get_midi_info((MIDI*)tunes[i].data,zmi);
6611 get_midi_text((MIDI*)tunes[i].data,zmi,text);
6612 }
6613
6614 midi_dlg[0].dp2=lfont;
6615 midi_dlg[3].dp = text;
6616 midi_dlg[3].d1 = midi_dlg[3].d2 = 0;
6617 midi_dlg[5].flags = (tunes[i].flags&tfDISABLESAVE) ? D_DISABLED : D_EXIT;
6618
6619 if(dialog_running)
6620 {
6621 scare_mouse();
6622 jwin_textbox_proc(MSG_DRAW,midi_dlg+3,0);
6623 d_savemidi_proc(MSG_DRAW,midi_dlg+5,0);
6624 unscare_mouse();
6625 }
6626 }
6627
6628 int32_t onMIDICredits()
6629 {
6630 text = (char*)malloc(4096);
6631 zmi = (midi_info*)malloc(sizeof(midi_info));
6632
6633 if(!text || !zmi)
6634 {
6635 jwin_alert(NULL,"Not enough memory",NULL,NULL,"OK",NULL,13,27,lfont);
6636 return D_O_K;
6637 }
6638
6639 bool do_pause_midi = midi_pos >= 0 && currmidi;
6640 auto restore_midi = currmidi;
6641 if(do_pause_midi)
6642 {
6643 paused_midi_pos = midi_pos;
6644 stop_midi();
6645 midi_paused=true;
6646 midi_suspended = midissuspHALTED;
6647 }
6648
6649 midi_dlg[0].dp2=lfont;
6650 midi_dlg[2].d1 = 0;
6651 midi_dlg[2].d2 = 0;
6652 midi_dlg[4].flags = D_EXIT;
6653 midi_dlg[5].flags = (tunes[midi_dlg[2].d1].flags&tfDISABLESAVE) ? D_DISABLED : D_EXIT;
6654
6655 listening = false;
6656 dialog_running=false;
6657 get_info(0);
6658
6659 dialog_running=true;
6660
6661 large_dialog(midi_dlg);
6662
6663 zc_popup_dialog(midi_dlg,0);
6664 dialog_running=false;
6665
6666 if(listening)
6667 music_stop();
6668
6669 if(do_pause_midi)
6670 {
6671 midi_suspended = midissuspRESUME;
6672 currmidi = restore_midi;
6673 midi_pos = paused_midi_pos;
6674 }
6675
6676 if(text) free(text);
6677 if(zmi) free(zmi);
6678 return D_O_K;
6679 }
6680
6681 int32_t onAbout()
6682 {
6683 char buf1[80]={0};
6684 std::ostringstream oss;
6685 sprintf(buf1,"%s (%s), Version: %s", ZC_PLAYER_NAME,PROJECT_NAME,ZC_PLAYER_V);
6686 oss << buf1 << '\n';
6687 sprintf(buf1, "%s, Build %d", ALPHA_VER_STR, VERSION_BUILD);
6688 oss << buf1 << '\n';
6689 sprintf(buf1,"Build Date: %s %s, %d at @ %s %s", dayextension(BUILDTM_DAY).c_str(), (char*)months[BUILDTM_MONTH], BUILDTM_YEAR, __TIME__, __TIMEZONE__);
6690 oss << buf1 << '\n';
6691 sprintf(buf1, "Built By: %s", DEV_SIGNOFF);
6692 oss << buf1 << '\n';
6693 sprintf(buf1, "Tag: %s", getReleaseTag());
6694 oss << buf1 << '\n';
6695
6696 InfoDialog("About ZC", oss.str()).show();
6697 return D_O_K;
6698 }
6699
6700 int32_t onQuest()
6701 {
6702 char fname[100];
6703 strcpy(fname, get_filename(qstpath));
6704 quest_dlg[0].dp2=lfont;
6705 quest_dlg[1].dp = fname;
6706
6707 if(QHeader.quest_number==0)
6708 sprintf(str_a,"Custom");
6709 else
6710 sprintf(str_a,"%d",QHeader.quest_number);
6711
6712 sprintf(str_s,"%s",VerStr(QHeader.zelda_version));
6713
6714 quest_dlg[11].d1 = quest_dlg[9].d1 = 0;
6715 quest_dlg[11].d2 = quest_dlg[9].d2 = 0;
6716
6717 large_dialog(quest_dlg);
6718
6719 zc_popup_dialog(quest_dlg, 0);
6720 return D_O_K;
6721 }
6722
6723 void call_vidmode_dlg();
6724 int32_t onVidMode()
6725 {
6726 call_vidmode_dlg();
6727 return D_O_K;
6728 }
6729
6730 #define addToHash(c,b,h) if(h->find(c ## key) == h->end()) \
6731 {(*h)[c ## key]=true;} else { if ( c ## key != 0 ) b = false;}
6732 //Added an extra statement, so that if the key is cleared to 0, the cleared
6733 //keybinding status need not be unique. -Z ( 1st April, 2019 )
6734
6735 void load_ukeys(int32_t* arr)
6736 {
6737 arr[ukey_a] = Akey;
6738 arr[ukey_b] = Bkey;
6739 arr[ukey_s] = Skey;
6740 arr[ukey_l] = Lkey;
6741 arr[ukey_r] = Rkey;
6742 arr[ukey_p] = Pkey;
6743 arr[ukey_ex1] = Exkey1;
6744 arr[ukey_ex2] = Exkey2;
6745 arr[ukey_ex3] = Exkey3;
6746 arr[ukey_ex4] = Exkey4;
6747 arr[ukey_du] = DUkey;
6748 arr[ukey_dd] = DDkey;
6749 arr[ukey_dl] = DLkey;
6750 arr[ukey_dr] = DRkey;
6751 arr[ukey_mod1a] = cheat_modifier_keys[0];
6752 arr[ukey_mod1b] = cheat_modifier_keys[1];
6753 arr[ukey_mod2a] = cheat_modifier_keys[2];
6754 arr[ukey_mod2b] = cheat_modifier_keys[3];
6755 };
6756
6757 static const char* ukey_names[] = {
6758 "A", "B", "Start", "L", "R", "Map",
6759 "Ex1", "Ex2", "Ex3", "Ex4", "Up", "Down",
6760 "Left", "Right", "Cheat Mod L1", "Cheat Mod L2",
6761 "Cheat Mod R1", "Cheat Mod R2",
6762 };
6763 std::string get_ukey_name(int32_t k)
6764 {
6765 if (k < num_ukey) return ukey_names[k];
6766 return "";
6767 }
6768
6769 int32_t onKeyboard()
6770 {
6771 int32_t a = Akey;
6772 int32_t b = Bkey;
6773 int32_t s = Skey;
6774 int32_t l = Lkey;
6775 int32_t r = Rkey;
6776 int32_t p = Pkey;
6777 int32_t ex1 = Exkey1;
6778 int32_t ex2 = Exkey2;
6779 int32_t ex3 = Exkey3;
6780 int32_t ex4 = Exkey4;
6781 int32_t du = DUkey;
6782 int32_t dd = DDkey;
6783 int32_t dl = DLkey;
6784 int32_t dr = DRkey;
6785 int32_t mod1a = cheat_modifier_keys[0];
6786 int32_t mod1b = cheat_modifier_keys[1];
6787 int32_t mod2a = cheat_modifier_keys[2];
6788 int32_t mod2b = cheat_modifier_keys[3];
6789 bool done=false;
6790 int32_t ret;
6791
6792 keyboard_control_dlg[0].dp2=lfont;
6793
6794 large_dialog(keyboard_control_dlg);
6795
6796 while(!done)
6797 {
6798 ret = zc_popup_dialog(keyboard_control_dlg,3);
6799
6800 if(ret==3) // OK
6801 {
6802 int32_t ukeys[num_ukey];
6803 load_ukeys(ukeys);
6804 std::vector<std::string> uniqueError;
6805 for(int32_t q = 0; q < num_ukey; ++q)
6806 {
6807 for(int32_t p = q+1; p < num_ukey; ++p)
6808 {
6809 if(ukeys[q] == ukeys[p] && ukeys[q] != 0)
6810 {
6811 char buf[64];
6812 sprintf(buf, "'%s' conflicts with '%s'", get_ukey_name(q).c_str(), get_ukey_name(p).c_str());
6813 std::string str(buf);
6814 uniqueError.push_back(str);
6815 }
6816 }
6817 }
6818 if(uniqueError.size() == 0)
6819 {
6820 done = true;
6821 save_control_configs(true);
6822 }
6823 else
6824 {
6825 box_start(1, "Duplicate Keys", lfont, sfont, false, keyboard_control_dlg[0].w,keyboard_control_dlg[0].h, 2);
6826 box_out("Cannot have duplicate keybinds!"); box_eol();
6827 for(std::vector<std::string>::iterator it = uniqueError.begin();
6828 it != uniqueError.end(); ++it)
6829 {
6830 box_out((*it).c_str()); box_eol();
6831 }
6832 box_end(true);
6833 }
6834 }
6835 else // Cancel
6836 {
6837 Akey = a;
6838 Bkey = b;
6839 Skey = s;
6840 Lkey = l;
6841 Rkey = r;
6842 Pkey = p;
6843 Exkey1 = ex1;
6844 Exkey2 = ex2;
6845 Exkey3 = ex3;
6846 Exkey4 = ex4;
6847 DUkey = du;
6848 DDkey = dd;
6849 DLkey = dl;
6850 DRkey = dr;
6851 cheat_modifier_keys[0] = mod1a;
6852 cheat_modifier_keys[1] = mod1b;
6853 cheat_modifier_keys[2] = mod2a;
6854 cheat_modifier_keys[3] = mod2b;
6855
6856 done=true;
6857 }
6858
6859 rest(1);
6860 }
6861
6862 return D_O_K;
6863 }
6864
6865 int32_t onGamepad()
6866 {
6867 int32_t a = Abtn;
6868 int32_t b = Bbtn;
6869 int32_t s = Sbtn;
6870 int32_t l = Lbtn;
6871 int32_t r = Rbtn;
6872 int32_t m = Mbtn;
6873 int32_t p = Pbtn;
6874 int32_t ex1 = Exbtn1;
6875 int32_t ex2 = Exbtn2;
6876 int32_t ex3 = Exbtn3;
6877 int32_t ex4 = Exbtn4;
6878 int32_t up = DUbtn;
6879 int32_t down = DDbtn;
6880 int32_t left = DLbtn;
6881 int32_t right = DRbtn;
6882
6883 gamepad_dlg[0].dp2=lfont;
6884 if(analog_movement)
6885 gamepad_dlg[56].flags|=D_SELECTED;
6886 else
6887 gamepad_dlg[56].flags&=~D_SELECTED;
6888
6889 large_dialog(gamepad_dlg);
6890
6891 int32_t ret = zc_popup_dialog(gamepad_dlg,4);
6892
6893 if(ret == 4) //OK
6894 {
6895 analog_movement = gamepad_dlg[56].flags&D_SELECTED;
6896 save_control_configs(false);
6897 }
6898 else //Cancel
6899 {
6900 Abtn = a;
6901 Bbtn = b;
6902 Sbtn = s;
6903 Lbtn = l;
6904 Rbtn = r;
6905 Mbtn = m;
6906 Pbtn = p;
6907 Exbtn1 = ex1;
6908 Exbtn2 = ex2;
6909 Exbtn3 = ex3;
6910 Exbtn4 = ex4;
6911 DUbtn = up;
6912 DDbtn = down;
6913 DLbtn = left;
6914 DRbtn = right;
6915 }
6916
6917 return D_O_K;
6918 }
6919
6920 int32_t onCheatKeys()
6921 {
6922 int32_t oldcheats[Cheat::Last][2];
6923 memcpy(oldcheats, cheatkeys, sizeof(cheatkeys));
6924
6925 bool done=false;
6926
6927 while(!done)
6928 {
6929 bool confirm = false;
6930 CheatKeysDialog(&confirm).show();
6931 if(confirm) // OK
6932 {
6933 std::vector<std::string> uniqueError;
6934 char buf[512];
6935 for(size_t q = 1; q < Cheat::Last; ++q)
6936 {
6937 if(cheatkeys[q][1] && !cheatkeys[q][0])
6938 {
6939 cheatkeys[q][0] = cheatkeys[q][1];
6940 cheatkeys[q][1] = 0;
6941 }
6942 }
6943 for(size_t q = 1; q < Cheat::Last; ++q)
6944 {
6945 if(!bindable_cheat((Cheat)q)) continue;
6946 for(size_t p = q+1; p < Cheat::Last; ++p)
6947 {
6948 if(!bindable_cheat((Cheat)p)) continue;
6949 for(size_t q2 = 0; q2 <= 1; ++q2)
6950 for(size_t p2 = 0; p2 <= 1; ++p2)
6951 {
6952 if(cheatkeys[q][q2] == cheatkeys[p][p2] && cheatkeys[q][q2] != 0)
6953 {
6954 uniqueError.push_back(fmt::format("'{}' ({}) conflicts with '{}' ({}) - both '{}'",
6955 cheat_to_string((Cheat)q), q2?"Alt":"Main",
6956 cheat_to_string((Cheat)p), p2?"Alt":"Main",
6957 get_keystr(cheatkeys[q][q2])));
6958 }
6959 }
6960 }
6961 }
6962 if(uniqueError.size() == 0)
6963 {
6964 done = true;
6965 save_cheatkeys();
6966 }
6967 else
6968 {
6969 box_start(1, "Duplicate Keys", lfont, sfont, false, 500,400, 2);
6970 box_out("Cannot have duplicate keybinds!"); box_eol();
6971 for(std::vector<std::string>::iterator it = uniqueError.begin();
6972 it != uniqueError.end(); ++it)
6973 {
6974 box_out((*it).c_str()); box_eol();
6975 }
6976 box_end(true);
6977 }
6978 }
6979 else // Cancel
6980 {
6981 memcpy(cheatkeys, oldcheats, sizeof(cheatkeys));
6982 done=true;
6983 }
6984 rest(1);
6985 }
6986
6987 return D_O_K;
6988 }
6989
6990 int32_t onSound()
6991 {
6992 if ( FFCore.coreflags&FFCORE_SCRIPTED_MIDI_VOLUME )
6993 {
6994 master_volume(-1,((int32_t)FFCore.usr_midi_volume));
6995 }
6996 if ( FFCore.coreflags&FFCORE_SCRIPTED_DIGI_VOLUME )
6997 {
6998 master_volume((int32_t)(FFCore.usr_digi_volume),1);
6999 }
7000 if ( FFCore.coreflags&FFCORE_SCRIPTED_MUSIC_VOLUME )
7001 {
7002 emusic_volume = (int32_t)FFCore.usr_music_volume;
7003 }
7004 if ( FFCore.coreflags&FFCORE_SCRIPTED_SFX_VOLUME )
7005 {
7006 sfx_volume = (int32_t)FFCore.usr_sfx_volume;
7007 }
7008 if ( FFCore.coreflags&FFCORE_SCRIPTED_PANSTYLE )
7009 {
7010 pan_style = (int32_t)FFCore.usr_panstyle;
7011 }
7012
7013 int32_t m = midi_volume;
7014 int32_t d = digi_volume;
7015 int32_t e = emusic_volume;
7016 int32_t b = zcmusic_bufsz;
7017 int32_t s = sfx_volume;
7018 int32_t p = pan_style;
7019 pan_style = vbound(pan_style,0,3);
7020
7021 sound_dlg[0].dp2=lfont;
7022
7023 large_dialog(sound_dlg);
7024
7025 midi_dp[1] = sound_dlg[6].x;
7026 midi_dp[2] = sound_dlg[6].y;
7027 digi_dp[1] = sound_dlg[7].x;
7028 digi_dp[2] = sound_dlg[7].y;
7029 emus_dp[1] = sound_dlg[8].x;
7030 emus_dp[2] = sound_dlg[8].y;
7031 buf_dp[1] = sound_dlg[9].x;
7032 buf_dp[2] = sound_dlg[9].y;
7033 sfx_dp[1] = sound_dlg[10].x;
7034 sfx_dp[2] = sound_dlg[10].y;
7035 pan_dp[1] = sound_dlg[11].x;
7036 pan_dp[2] = sound_dlg[11].y;
7037 sound_dlg[15].d2 = (midi_volume==255) ? 32 : midi_volume>>3;
7038 sound_dlg[16].d2 = (digi_volume==255) ? 32 : digi_volume>>3;
7039 sound_dlg[17].d2 = (emusic_volume==255) ? 32 : emusic_volume>>3;
7040 sound_dlg[18].d2 = zcmusic_bufsz;
7041 sound_dlg[19].d2 = (sfx_volume==255) ? 32 : sfx_volume>>3;
7042 sound_dlg[20].d2 = pan_style;
7043
7044 int32_t ret = zc_popup_dialog(sound_dlg,1);
7045
7046 if(ret==2)
7047 {
7048 master_volume(digi_volume,midi_volume);
7049
7050 for(int32_t i=0; i<WAV_COUNT; ++i)
7051 {
7052 //allegro assertion fails when passing in -1 as voice -DD
7053 if(sfx_voice[i] > 0)
7054 voice_set_volume(sfx_voice[i], sfx_volume);
7055 }
7056 zc_set_config(sfx_sect,"digi",digi_volume);
7057 zc_set_config(sfx_sect,"midi",midi_volume);
7058 zc_set_config(sfx_sect,"sfx",sfx_volume);
7059 zc_set_config(sfx_sect,"emusic",emusic_volume);
7060 zc_set_config(sfx_sect,"pan",pan_style);
7061 zc_set_config(sfx_sect,"zcmusic_bufsz",zcmusic_bufsz);
7062 }
7063 else
7064 {
7065 midi_volume = m;
7066 digi_volume = d;
7067 emusic_volume = e;
7068 zcmusic_bufsz = b;
7069 sfx_volume = s;
7070 pan_style = p;
7071 }
7072
7073 return D_O_K;
7074 }
7075
7076 int32_t queding(char const* s1, char const* s2, char const* s3)
7077 {
7078 return jwin_alert(ZC_str,s1,s2,s3,"&Yes","&No",'y','n',lfont);
7079 }
7080
7081 int32_t onQuit()
7082 {
7083 if(Playing)
7084 {
7085 int32_t ret=0;
7086
7087 if(get_bit(quest_rules, qr_NOCONTINUE))
7088 {
7089 if(standalone_mode)
7090 {
7091 ret=queding("End current game?",
7092 "The continue screen is disabled; the game",
7093 "will be reloaded from the last save.");
7094 }
7095 else
7096 {
7097 ret=queding("End current game?",
7098 "The continue screen is disabled. You will",
7099 "be returned to the file select screen.");
7100 }
7101 }
7102 else
7103 ret=queding("End current game?",NULL,NULL);
7104
7105 if(ret==1)
7106 {
7107 disableClickToFreeze=false;
7108 Quit=qQUIT;
7109
7110 // Trying to evade a door repair charge?
7111 if(repaircharge)
7112 {
7113 game->change_drupy(-repaircharge);
7114 repaircharge=0;
7115 }
7116
7117 return D_CLOSE;
7118 }
7119 }
7120
7121 return D_O_K;
7122 }
7123
7124 int32_t onTryQuitMenu()
7125 {
7126 return onTryQuit(true);
7127 }
7128
7129 int32_t onTryQuit(bool inMenu)
7130 {
7131 if(Playing && !(GameFlags & GAMEFLAG_NO_F6))
7132 {
7133 if(get_bit(quest_rules,qr_OLD_F6))
7134 {
7135 if(inMenu) onQuit();
7136 else /*if(!get_bit(quest_rules, qr_NOCONTINUE))*/ f_Quit(qQUIT);
7137 }
7138 else
7139 {
7140 disableClickToFreeze=false;
7141 GameFlags |= GAMEFLAG_TRYQUIT;
7142 }
7143 return D_CLOSE;
7144 }
7145
7146 return D_O_K;
7147 }
7148
7149 int32_t onReset()
7150 {
7151 if(queding(" Reset system? ",NULL,NULL)==1)
7152 {
7153 disableClickToFreeze=false;
7154 Quit=qRESET;
7155 replay_quit();
7156 return D_CLOSE;
7157 }
7158
7159 return D_O_K;
7160 }
7161
7162 int32_t onExit()
7163 {
7164 if(queding(" Quit Zelda Classic? ",NULL,NULL)==1)
7165 {
7166 Quit=qEXIT;
7167 return D_CLOSE;
7168 }
7169
7170 return D_O_K;
7171 }
7172
7173 int32_t onTitle_NES()
7174 {
7175 title_version=0;
7176 zc_set_config(cfg_sect,"title",title_version);
7177 return D_O_K;
7178 }
7179 int32_t onTitle_DX()
7180 {
7181 title_version=1;
7182 zc_set_config(cfg_sect,"title",title_version);
7183 return D_O_K;
7184 }
7185 int32_t onTitle_25()
7186 {
7187 title_version=2;
7188 zc_set_config(cfg_sect,"title",title_version);
7189 return D_O_K;
7190 }
7191
7192 int32_t onDebug()
7193 {
7194 if(debug_enabled)
7195 set_debug(!get_debug());
7196 return D_O_K;
7197 }
7198
7199 int32_t onHeartBeep()
7200 {
7201 heart_beep=!heart_beep;
7202 zc_set_config(cfg_sect,"heart_beep",heart_beep);
7203 return D_O_K;
7204 }
7205
7206 int32_t onSaveIndicator()
7207 {
7208 use_save_indicator=!use_save_indicator;
7209 zc_set_config(cfg_sect,"save_indicator",use_save_indicator);
7210 return D_O_K;
7211 }
7212
7213 int32_t onEpilepsy()
7214 {
7215 if(jwin_alert3(
7216 "Epilepsy Flash Reduction",
7217 "Enabling this will reduce the intensity of flashing and screen wave effects.",
7218 "Disabling this will restore standard flash and wavy behaviour.",
7219 "Proceed?",
7220 "&Yes",
7221 "&No",
7222 NULL,
7223 'y',
7224 'n',
7225 0,
7226 lfont) == 1)
7227 {
7228 epilepsyFlashReduction = epilepsyFlashReduction ? 0 : 1;
7229 zc_set_config("zeldadx","checked_epilepsy",1);
7230 zc_set_config(cfg_sect,"epilepsy_flash_reduction",epilepsyFlashReduction);
7231 }
7232 return D_O_K;
7233 }
7234
7235 int32_t onTriforce()
7236 {
7237 for(int32_t i=0; i<MAXINITTABS; ++i)
7238 {
7239 init_tabs[i].flags&=~D_SELECTED;
7240 }
7241
7242 init_tabs[3].flags=D_SELECTED;
7243 return onCheatConsole();
7244 /*triforce_dlg[0].dp2=lfont;
7245 for(int32_t i=1; i<=8; i++)
7246 triforce_dlg[i].flags = (game->lvlitems[i] & liTRIFORCE) ? D_SELECTED : 0;
7247
7248 if(zc_popup_dialog (triforce_dlg,-1)==9)
7249 {
7250 for(int32_t i=1; i<=8; i++)
7251 {
7252 game->lvlitems[i] &= ~liTRIFORCE;
7253 game->lvlitems[i] |= (triforce_dlg[i].flags & D_SELECTED) ? liTRIFORCE : 0;
7254 }
7255 }
7256 return D_O_K;*/
7257 }
7258
7259 bool rc = false;
7260 /*
7261 int32_t onEquipment()
7262 {
7263 for (int32_t i=0; i<MAXINITTABS; ++i)
7264 {
7265 init_tabs[i].flags&=~D_SELECTED;
7266 }
7267 init_tabs[0].flags=D_SELECTED;
7268 return onCheatConsole();
7269 }
7270 */
7271
7272 int32_t onItems()
7273 {
7274 for(int32_t i=0; i<MAXINITTABS; ++i)
7275 {
7276 init_tabs[i].flags&=~D_SELECTED;
7277 }
7278
7279 init_tabs[1].flags=D_SELECTED;
7280 return onCheatConsole();
7281 }
7282
7283 static DIALOG getnum_dlg[] =
7284 {
7285 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
7286 { jwin_win_proc, 80, 80, 160, 72, vc(0), vc(11), 0, D_EXIT, 0, 0, NULL, NULL, NULL },
7287 { jwin_text_proc, 104, 104+4, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Number:", NULL, NULL },
7288 { jwin_edit_proc, 168, 104, 48, 16, 0, 0, 0, 0, 6, 0, NULL, NULL, NULL },
7289 { jwin_button_proc, 90, 126, 61, 21, vc(0), vc(11), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
7290 { jwin_button_proc, 170, 126, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
7291 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7292 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7293 };
7294
7295 int32_t getnumber(const char *prompt,int32_t initialval)
7296 {
7297 char buf[20];
7298 sprintf(buf,"%d",initialval);
7299 getnum_dlg[0].dp=(void *)prompt;
7300 getnum_dlg[0].dp2=lfont;
7301 getnum_dlg[2].dp=buf;
7302
7303 large_dialog(getnum_dlg);
7304
7305 if(zc_popup_dialog(getnum_dlg,2)==3)
7306 return atoi(buf);
7307
7308 return initialval;
7309 }
7310
7311 int32_t onLife()
7312 {
7313 int value = vbound(getnumber("Life",game->get_life()),1,game->get_maxlife());
7314 cheats_enqueue(Cheat::Life, value);
7315 return D_O_K;
7316 }
7317
7318 int32_t onHeartC()
7319 {
7320 int max_life = vbound(getnumber("Heart Containers",game->get_maxlife()/game->get_hp_per_heart()),1,4095) * game->get_hp_per_heart();
7321 int life = vbound(getnumber("Life",game->get_life()/game->get_hp_per_heart()),1,max_life/game->get_hp_per_heart())*game->get_hp_per_heart();
7322 cheats_enqueue(Cheat::MaxLife, max_life);
7323 cheats_enqueue(Cheat::Life, life);
7324 return D_O_K;
7325 }
7326
7327 int32_t onMagicC()
7328 {
7329 int max_magic = vbound(getnumber("Magic Containers",game->get_maxmagic()/game->get_mp_per_block()),0,2047) * game->get_mp_per_block();
7330 int magic = vbound(getnumber("Magic",game->get_magic()/game->get_mp_per_block()),0,game->get_maxmagic()/game->get_mp_per_block())*game->get_mp_per_block();
7331 cheats_enqueue(Cheat::MaxMagic, max_magic);
7332 cheats_enqueue(Cheat::Magic, magic);
7333 return D_O_K;
7334 }
7335
7336 int32_t onRupies()
7337 {
7338 int value = vbound(getnumber("Rupees",game->get_rupies()),0,game->get_maxcounter(1));
7339 cheats_enqueue(Cheat::Rupies, value);
7340 return D_O_K;
7341 }
7342
7343 int32_t onMaxBombs()
7344 {
7345 int value = vbound(getnumber("Max Bombs",game->get_maxbombs()),0,0xFFFF);
7346 cheats_enqueue(Cheat::MaxBombs, value);
7347 cheats_enqueue(Cheat::Bombs, value);
7348 return D_O_K;
7349 }
7350
7351 int32_t onRefillLife()
7352 {
7353 cheats_enqueue(Cheat::Life, game->get_maxlife());
7354 return D_O_K;
7355 }
7356 int32_t onRefillMagic()
7357 {
7358 cheats_enqueue(Cheat::Magic, game->get_maxmagic());
7359 return D_O_K;
7360 }
7361 int32_t onClock()
7362 {
7363 cheats_enqueue(Cheat::Clock);
7364 return D_O_K;
7365 }
7366
7367 int32_t onQstPath()
7368 {
7369 char path[2048];
7370
7371 chop_path(qstdir);
7372 strcpy(path,qstdir);
7373
7374 go();
7375
7376 if(jwin_dfile_select_ex("Quest File Directory", path, "qst", 2048, -1, -1, lfont))
7377 {
7378 chop_path(path);
7379 fix_filename_case(path);
7380 fix_filename_slashes(path);
7381 strcpy(qstdir,path);
7382 strcpy(qstpath,qstdir);
7383 }
7384
7385 comeback();
7386 return D_O_K;
7387 }
7388
7389 #include "dialog/cheat_dialog.h"
7390 int32_t onCheat()
7391 {
7392 call_setcheat_dialog();
7393 game->set_cheat(maxcheat);
7394 if(cheat) game->did_cheat(true);
7395 return D_O_K;
7396 }
7397
7398 int32_t onCheatRupies()
7399 {
7400 cheats_enqueue(Cheat::Rupies, game->get_maxcounter(1));
7401 return D_O_K;
7402 }
7403
7404 int32_t onCheatArrows()
7405 {
7406 cheats_enqueue(Cheat::Arrows, game->get_maxarrows());
7407 return D_O_K;
7408 }
7409
7410 int32_t onCheatBombs()
7411 {
7412 cheats_enqueue(Cheat::Bombs, game->get_maxbombs(), game->get_maxcounter(6));
7413 return D_O_K;
7414 }
7415
7416 // *** screen saver
7417
7418 6510614 int32_t after_time()
7419 {
7420
1/2
✓ Branch 0 taken 6510614 times.
✗ Branch 1 not taken.
6510614 if(ss_enable == 0)
7421 return INT_MAX;
7422
7423
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6510614 times.
6510614 if(ss_after <= 0)
7424 return 5 * 60;
7425
7426
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6510614 times.
6510614 if(ss_after <= 3)
7427 return ss_after * 15 * 60;
7428
7429
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6510614 times.
6510614 if(ss_after <= 13)
7430 return (ss_after - 3) * 60 * 60;
7431
7432 6510614 return MAX_IDLE + 1;
7433 6510614 }
7434
7435 static const char *after_str[15] =
7436 {
7437 " 5 sec", "15 sec", "30 sec", "45 sec", " 1 min", " 2 min", " 3 min",
7438 " 4 min", " 5 min", " 6 min", " 7 min", " 8 min", " 9 min", "10 min",
7439 "Never"
7440 };
7441
7442 const char *after_list(int32_t index, int32_t *list_size)
7443 {
7444 if(index < 0)
7445 {
7446 *list_size = 15;
7447 return NULL;
7448 }
7449
7450 return after_str[index];
7451 }
7452
7453 29 static ListData after__list(after_list, &font);
7454
7455 static DIALOG scrsaver_dlg[] =
7456 {
7457 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
7458 29 { jwin_win_proc, 32, 64, 256, 136, 0, 0, 0, D_EXIT, 0, 0, (void *) "Screen Saver Settings", NULL, NULL },
7459 29 { jwin_frame_proc, 42, 92, 236, 70, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
7460 29 { jwin_text_proc, 60, 104, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Run After", NULL, NULL },
7461 29 { jwin_text_proc, 60, 128, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Speed", NULL, NULL },
7462 29 { jwin_text_proc, 60, 144, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Density", NULL, NULL },
7463 29 { jwin_droplist_proc, 144, 100, 96, 16, 0, 0, 0, 0, 0, 0, (void *) &after__list, NULL, NULL },
7464 29 { jwin_slider_proc, 144, 128, 116, 8, vc(0), jwin_pal[jcBOX], 0, 0, 6, 0, NULL, NULL, NULL },
7465 29 { jwin_slider_proc, 144, 144, 116, 8, vc(0), jwin_pal[jcBOX], 0, 0, 6, 0, NULL, NULL, NULL },
7466 29 { jwin_button_proc, 42, 170, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
7467 29 { jwin_button_proc, 124, 170, 72, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Preview", NULL, NULL },
7468 29 { jwin_button_proc, 218, 170, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
7469 29 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7470 29 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7471 };
7472
7473 int32_t onScreenSaver()
7474 {
7475 scrsaver_dlg[0].dp2=lfont;
7476 int32_t oldcfgs[3];
7477 scrsaver_dlg[5].d1 = scrsaver_dlg[5].d2 = oldcfgs[0] = ss_after;
7478 scrsaver_dlg[6].d2 = oldcfgs[1] = ss_speed;
7479 scrsaver_dlg[7].d2 = oldcfgs[2] = ss_density;
7480
7481 large_dialog(scrsaver_dlg);
7482
7483 int32_t ret = zc_popup_dialog(scrsaver_dlg,-1);
7484
7485 if(ret == 8 || ret == 9)
7486 {
7487 ss_after = scrsaver_dlg[5].d1;
7488 ss_speed = scrsaver_dlg[6].d2;
7489 ss_density = scrsaver_dlg[7].d2;
7490 if(oldcfgs[0] != ss_after)
7491 zc_set_config(cfg_sect,"ss_after",ss_after);
7492 if(oldcfgs[1] != ss_speed)
7493 zc_set_config(cfg_sect,"ss_speed",ss_speed);
7494 if(oldcfgs[2] != ss_density)
7495 zc_set_config(cfg_sect,"ss_density",ss_density);
7496 }
7497
7498 if(ret == 9)
7499 // preview Screen Saver
7500 {
7501 clear_keybuf();
7502 scare_mouse();
7503 Matrix(ss_speed, ss_density, 30);
7504 system_pal();
7505 unscare_mouse();
7506 }
7507
7508 return D_O_K;
7509 }
7510
7511 /***** Menus *****/
7512
7513 static MENU game_menu[] =
7514 {
7515 { (char *)"&Continue\tESC", onContinue, NULL, 0, NULL },
7516 { (char *)"", NULL, NULL, 0, NULL },
7517 { (char *)"L&oad Quest...", onCustomGame, NULL, 0, NULL },
7518 { (char *)"&End Game\tF6", onTryQuitMenu, NULL, 0, NULL },
7519 { (char *)"", NULL, NULL, 0, NULL },
7520 #ifdef __EMSCRIPTEN__
7521 { (char *)"&Reset\tF7", onReset, NULL, 0, NULL },
7522 #elif defined(ALLEGRO_MACOSX)
7523 { (char *)"&Reset\tF7", onReset, NULL, 0, NULL },
7524 { (char *)"&Quit\tF8", onExit, NULL, 0, NULL },
7525 #else
7526 { (char *)"&Reset\tF9", onReset, NULL, 0, NULL },
7527 { (char *)"&Quit\tF10", onExit, NULL, 0, NULL },
7528 #endif
7529 { NULL, NULL, NULL, 0, NULL }
7530 };
7531
7532 static MENU title_menu[] =
7533 {
7534 { (char *)"&Original", onTitle_NES, NULL, 0, NULL },
7535 { (char *)"&Zelda Classic", onTitle_DX, NULL, 0, NULL },
7536 { (char *)"Zelda Classic &2.50", onTitle_25, NULL, 0, NULL },
7537 { NULL, NULL, NULL, 0, NULL }
7538 };
7539
7540 static MENU snapshot_format_menu[] =
7541 {
7542 { (char *)"&BMP", onSetSnapshotFormat, NULL, 0, NULL },
7543 { (char *)"&GIF", onSetSnapshotFormat, NULL, 0, NULL },
7544 { (char *)"&JPG", onSetSnapshotFormat, NULL, 0, NULL },
7545 { (char *)"&PNG", onSetSnapshotFormat, NULL, 0, NULL },
7546 { (char *)"PC&X", onSetSnapshotFormat, NULL, 0, NULL },
7547 { (char *)"&TGA", onSetSnapshotFormat, NULL, 0, NULL },
7548 { NULL, NULL, NULL, 0, NULL }
7549 };
7550
7551 static MENU controls_menu[] =
7552 {
7553 { (char *)"Key&board...", onKeyboard, NULL, 0, NULL },
7554 { (char *)"&Gamepad...", onGamepad, NULL, 0, NULL },
7555 { (char *)"&Cheat Keys...", onCheatKeys, NULL, 0, NULL },
7556 { NULL, NULL, NULL, 0, NULL }
7557 };
7558
7559 static MENU name_entry_mode_menu[] =
7560 {
7561 { (char *)"&Keyboard", onKeyboardEntry, NULL, 0, NULL },
7562 { (char *)"&Letter Grid", onLetterGridEntry, NULL, 0, NULL },
7563 { (char *)"&Extended Letter Grid", onExtLetterGridEntry, NULL, 0, NULL },
7564 { NULL, NULL, NULL, 0, NULL }
7565 };
7566
7567 static void set_controls_menu_active()
7568 {
7569
7570 }
7571
7572 static MENU settings_menu[] =
7573 {
7574 { (char *)"&Sound...", onSound, NULL, 0, NULL },
7575 { (char *)"C&ontrols", NULL, controls_menu, 0, NULL },
7576 { (char *)"&Title Screen", NULL, title_menu, 0, NULL },
7577 { (char *)"Name &Entry Mode", NULL, name_entry_mode_menu, 0, NULL },
7578 { (char *)"", NULL, NULL, 0, NULL },
7579 { (char *)"&Cap FPS\tF1", onVsync, NULL, 0, NULL },
7580 { (char *)"Show &FPS\tF2", onShowFPS, NULL, 0, NULL },
7581 { (char *)"Show Trans. &Layers", onTransLayers, NULL, 0, NULL },
7582 { (char *)"Up+A+B To &Quit", onNESquit, NULL, 0, NULL },
7583 { (char *)"Click to Freeze", onClickToFreeze, NULL, 0, NULL },
7584 { (char *)"Autosave Window Size Changes", onSaveDragResize, NULL, 0, NULL },
7585 { (char *)"Lock Aspect Ratio", onDragAspect, NULL, 0, NULL },
7586 { (char *)"Window Position Saving", onWinPosSave, NULL, 0, NULL },
7587 { (char *)"Volume &Keys", onVolKeys, NULL, 0, NULL },
7588 { (char *)"Cont. &Heart Beep", onHeartBeep, NULL, 0, NULL },
7589 { (char *)"Sa&ve Indicator", onSaveIndicator, NULL, 0, NULL },
7590 { (char *)"Epilepsy Flash Reduction", onEpilepsy, NULL, 0, NULL },
7591 { (char *)"S&napshot Format", NULL, snapshot_format_menu, 0, NULL },
7592 { (char *)"", NULL, NULL, 0, NULL },
7593 { (char *)"Debu&g", onDebug, NULL, 0, NULL },
7594 { (char *)"", NULL, NULL, 0, NULL },
7595 { NULL, NULL, NULL, 0, NULL }
7596 };
7597
7598
7599 static MENU misc_menu[] =
7600 {
7601 { (char *)"&About...", onAbout, NULL, 0, NULL },
7602 { (char *)"&Credits...", onCredits, NULL, 0, NULL },
7603 { (char *)"&Fullscreen", onFullscreenMenu, NULL, 0, NULL },
7604 { (char *)"&Video Mode...", onVidMode, NULL, 0, NULL },
7605 { (char *)"", NULL, NULL, 0, NULL },
7606 //5
7607 { (char *)"&Quest Info...", onQuest, NULL, 0, NULL },
7608 { (char *)"Quest &MIDI Info...", onMIDICredits, NULL, 0, NULL },
7609 { (char *)"Quest &Directory...", onQstPath, NULL, 0, NULL },
7610 { (char *)"", NULL, NULL, 0, NULL },
7611 { (char *)"Take &Snapshot\tF12", onSnapshot, NULL, 0, NULL },
7612 //10
7613 { (char *)"Sc&reen Saver...", onScreenSaver, NULL, 0, NULL },
7614 { (char *)"Save ZC Configuration", OnSaveZCConfig, NULL, 0, NULL },
7615 { (char *)"Show ZASM Debugger", onConsoleZASM, NULL, 0, NULL },
7616 { (char *)"Show ZScript Debugger", onConsoleZScript, NULL, 0, NULL },
7617 { (char *)"Clear Console on Load", onClrConsoleOnReload, NULL, 0, NULL },
7618 //15
7619 { (char *)"Clear Console on QST Load", onClrConsoleOnLoad, NULL, 0, NULL },
7620 { (char *)"Clear Directory Cache", OnnClearQuestDir, NULL, 0, NULL },
7621 { (char *)"Modules", NULL, zcmodule_menu, 0, NULL },
7622 { (char *)"Replay", NULL, replay_menu, 0, NULL },
7623
7624 { NULL, NULL, NULL, 0, NULL }
7625 };
7626
7627 static MENU refill_menu[] =
7628 {
7629 { (char *)"&Life", onRefillLife, NULL, 0, NULL },
7630 { (char *)"&Magic", onRefillMagic, NULL, 0, NULL },
7631 { (char *)"&Bombs", onCheatBombs, NULL, 0, NULL },
7632 { (char *)"&Rupees", onCheatRupies, NULL, 0, NULL },
7633 { (char *)"&Arrows", onCheatArrows, NULL, 0, NULL },
7634 { NULL, NULL, NULL, 0, NULL }
7635 };
7636
7637 static MENU show_menu[] =
7638 {
7639 { (char *)"Combos", onShowLayer0, NULL, 0, NULL },
7640 { (char *)"Layer 1", onShowLayer1, NULL, 0, NULL },
7641 { (char *)"Layer 2", onShowLayer2, NULL, 0, NULL },
7642 { (char *)"Layer 3", onShowLayer3, NULL, 0, NULL },
7643 { (char *)"Layer 4", onShowLayer4, NULL, 0, NULL },
7644 { (char *)"Layer 5", onShowLayer5, NULL, 0, NULL },
7645 { (char *)"Layer 6", onShowLayer6, NULL, 0, NULL },
7646 { (char *)"Overhead Combos", onShowLayerO, NULL, 0, NULL },
7647 { (char *)"Push Blocks", onShowLayerP, NULL, 0, NULL },
7648 { (char *)"Freeform Combos", onShowLayerF, NULL, 0, NULL },
7649 { (char *)"Sprites", onShowLayerS, NULL, 0, NULL },
7650 { (char *)"", NULL, NULL, 0, NULL },
7651 { (char *)"Current FFC Scripts", onShowFFScripts, NULL, 0, NULL },
7652 { (char *)"", NULL, NULL, 0, NULL },
7653 { (char *)"Walkability", onShowLayerW, NULL, 0, NULL },
7654 { (char *)"Hitboxes", onShowHitboxes, NULL, 0, NULL },
7655 { (char *)"Effects", onShowLayerE, NULL, 0, NULL },
7656 { (char *)"Info Opacity", onShowInfoOpacity, NULL, 0, NULL },
7657 { NULL, NULL, NULL, 0, NULL }
7658 };
7659
7660 static MENU cheat_menu[] =
7661 {
7662 { (char *)"Set &Cheat", onCheat, NULL, 0, NULL },
7663 { (char *)"", NULL, NULL, 0, NULL },
7664 { (char *)"Re&fill", NULL, refill_menu, 0, NULL },
7665 { (char *)"", NULL, NULL, 0, NULL },
7666 { (char *)"&Invincible", onClock, NULL, 0, NULL },
7667 { (char *)"Ma&x Bombs...", onMaxBombs, NULL, 0, NULL },
7668 { (char *)"&Heart Containers...", onHeartC, NULL, 0, NULL },
7669 { (char *)"&Magic Containers...", onMagicC, NULL, 0, NULL },
7670 { (char *)"", NULL, NULL, 0, NULL },
7671 { (char *)"&Player Data...", onCheatConsole, NULL, 0, NULL },
7672 { (char *)"", NULL, NULL, 0, NULL },
7673 { (char *)"Walk Through &Walls", onNoWalls, NULL, 0, NULL },
7674 { (char *)"Player Ignores Side&view", onIgnoreSideview, NULL, 0, NULL },
7675 { (char *)"&Quick Movement", onGoFast, NULL, 0, NULL },
7676 { (char *)"&Kill All Enemies", onKillCheat, NULL, 0, NULL },
7677 { (char *)"Trigger &Secrets", onSecretsCheat, NULL, 0, NULL },
7678 { (char *)"Trigger Secrets Perm", onSecretsCheatPerm, NULL, 0, NULL },
7679 { (char *)"Show/Hide Layer", NULL, show_menu, 0, NULL },
7680 { (char *)"Toggle &Light", onLightSwitch, NULL, 0, NULL },
7681 { (char *)"&Goto Location...", onGoTo, NULL, 0, NULL },
7682 { NULL, NULL, NULL, 0, NULL }
7683 };
7684
7685 static MENU fixes_menu[] =
7686 {
7687 { (char *)"Windows MIDI Patch", onMIDIPatch, NULL, 0, NULL },
7688 { NULL, NULL, NULL, 0, NULL }
7689 };
7690
7691 #if DEVLEVEL > 0
7692 int32_t devLogging();
7693 int32_t devDebug();
7694 int32_t devTimestmp();
7695 #if DEVLEVEL > 1
7696 int32_t setCheat();
7697 #endif //DEVLEVEL > 1
7698 enum
7699 {
7700 dv_log,
7701 // dv_dbg,
7702 dv_tmpstmp,
7703 #if DEVLEVEL > 1
7704 dv_nil,
7705 dv_setcheat,
7706 #endif //DEVLEVEL > 1
7707 dv_max
7708 };
7709 static MENU dev_menu[] =
7710 {
7711 { (char *)"&Force Error Log", devLogging, NULL, 0, NULL },
7712 // { (char *)"&Extra Debug Log", devDebug, NULL, 0, NULL },
7713 { (char *)"&Timestamp Log", devTimestmp, NULL, 0, NULL },
7714 #if DEVLEVEL > 1
7715 { (char *)"", NULL, NULL, 0, NULL },
7716 { (char *)"Set &Cheat", setCheat, NULL, 0, NULL },
7717 #endif //DEVLEVEL > 1
7718 { NULL, NULL, NULL, 0, NULL }
7719 };
7720 int32_t devLogging()
7721 {
7722 dev_logging = !dev_logging;
7723 dev_menu[dv_log].flags = dev_logging ? D_SELECTED : 0;
7724 return D_O_K;
7725 }
7726 // int32_t devDebug()
7727 // {
7728 // dev_debug = !dev_debug;
7729 // dev_menu[dv_dbg].flags = dev_debug ? D_SELECTED : 0;
7730 // return D_O_K;
7731 // }
7732 int32_t devTimestmp()
7733 {
7734 dev_timestmp = !dev_timestmp;
7735 dev_menu[dv_tmpstmp].flags = dev_timestmp ? D_SELECTED : 0;
7736 return D_O_K;
7737 }
7738 #if DEVLEVEL > 1
7739 int32_t setCheat()
7740 {
7741 cheat = (vbound(getnumber("Cheat Level",cheat), 0, 4));
7742 return D_O_K;
7743 }
7744 #endif //DEVLEVEL > 1
7745 #endif //DEVLEVEL > 0
7746
7747 MENU the_player_menu[] =
7748 {
7749 { (char *)"&Game", NULL, game_menu, 0, NULL },
7750 { (char *)"&Settings", NULL, settings_menu, 0, NULL },
7751 { (char *)"&Cheat", NULL, cheat_menu, 0, NULL },
7752 { (char *)"&Fixes", NULL, fixes_menu, 0, NULL },
7753 { (char *)"&ZC", NULL, misc_menu, 0, NULL },
7754 #if DEVLEVEL > 0
7755 { (char *)"&Dev", NULL, dev_menu, 0, NULL },
7756 #endif
7757 { NULL, NULL, NULL, 0, NULL }
7758 };
7759
7760 MENU the_player_menu2[] =
7761 {
7762 { (char *)"&Game", NULL, game_menu, 0, NULL },
7763 { (char *)"&Settings", NULL, settings_menu, 0, NULL },
7764 { (char *)"&Fixes", NULL, fixes_menu, 0, NULL },
7765 { (char *)"&ZC", NULL, misc_menu, 0, NULL },
7766 #if DEVLEVEL > 0
7767 { (char *)"&Dev", NULL, dev_menu, 0, NULL },
7768 #endif
7769 { NULL, NULL, NULL, 0, NULL }
7770 };
7771
7772 int32_t onMIDIPatch()
7773 {
7774 if(jwin_alert3(
7775 "Toggle Windows MIDI Fix",
7776 "This action will change whether ZC Player auto-restarts a MIDI at its",
7777 "last index if you move ZC Player out of focus, then back into focus.",
7778 "Proceed?",
7779 "&Yes",
7780 "&No",
7781 NULL,
7782 'y',
7783 'n',
7784 0,
7785 lfont) == 1)
7786 {
7787 midi_patch_fix = midi_patch_fix ? 0 : 1;
7788 zc_set_config("zeldadx","midi_patch_fix",midi_patch_fix);
7789 }
7790 fixes_menu[0].flags =(midi_patch_fix)?D_SELECTED:0;
7791 return D_O_K;
7792 }
7793
7794 int32_t onKeyboardEntry()
7795 {
7796 NameEntryMode=0;
7797 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
7798 return D_O_K;
7799 }
7800
7801 int32_t onLetterGridEntry()
7802 {
7803 NameEntryMode=1;
7804 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
7805 return D_O_K;
7806 }
7807
7808 int32_t onExtLetterGridEntry()
7809 {
7810 NameEntryMode=2;
7811 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
7812 return D_O_K;
7813 }
7814
7815 static BITMAP* oldscreen;
7816 int32_t onFullscreenMenu()
7817 {
7818 // super hacks
7819 screen = oldscreen;
7820 if (onFullscreen() == D_REDRAW)
7821 {
7822 oldscreen = screen;
7823 }
7824 screen = menu_bmp;
7825 misc_menu[2].flags =(isFullScreen()==1)?D_SELECTED:0;
7826 return D_O_K;
7827 }
7828
7829 29 void fix_menu()
7830 {
7831
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
29 if(!debug_enabled)
7832 29 settings_menu[18].text = NULL;
7833 29 }
7834
7835 static DIALOG system_dlg[] =
7836 {
7837 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
7838 { jwin_menu_proc, 0, 0, 0, 0, 0, 0, 0, D_USER, 0, 0, (void *) the_player_menu, NULL, NULL },
7839 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F1, 0, (void *) onVsync, NULL, NULL },
7840 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F2, 0, (void *) onShowFPS, NULL, NULL },
7841 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F6, 0, (void *) onTryQuitMenu, NULL, NULL },
7842 #ifndef ALLEGRO_MACOSX
7843 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F9, 0, (void *) onReset, NULL, NULL },
7844 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F10, 0, (void *) onExit, NULL, NULL },
7845 #else
7846 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F7, 0, (void *) onReset, NULL, NULL },
7847 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F8, 0, (void *) onExit, NULL, NULL },
7848 #endif
7849 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F12, 0, (void *) onSnapshot, NULL, NULL },
7850 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_TAB, 0, (void *) onDebug, NULL, NULL },
7851 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7852 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7853 };
7854
7855 static DIALOG system_dlg2[] =
7856 {
7857 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
7858 { jwin_menu_proc, 0, 0, 0, 0, 0, 0, 0, D_USER, 0, 0, (void *) the_player_menu2, NULL, NULL },
7859 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F1, 0, (void *) onVsync, NULL, NULL },
7860 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F2, 0, (void *) onShowFPS, NULL, NULL },
7861 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F6, 0, (void *) onTryQuitMenu, NULL, NULL },
7862 #ifndef ALLEGRO_MACOSX
7863 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F9, 0, (void *) onReset, NULL, NULL },
7864 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F10, 0, (void *) onExit, NULL, NULL },
7865 #else
7866 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F7, 0, (void *) onReset, NULL, NULL },
7867 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F8, 0, (void *) onExit, NULL, NULL },
7868 #endif
7869 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F12, 0, (void *) onSnapshot, NULL, NULL },
7870 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_TAB, 0, (void *) onDebug, NULL, NULL },
7871 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7872 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7873 };
7874
7875 void reset_snapshot_format_menu()
7876 {
7877 for(int32_t i=0; i<ssfmtMAX; ++i)
7878 {
7879 snapshot_format_menu[i].flags=0;
7880 }
7881 }
7882
7883 int32_t onSetSnapshotFormat()
7884 {
7885 switch(active_menu->text[1])
7886 {
7887 case 'B': //"&BMP"
7888 SnapshotFormat=0;
7889 break;
7890
7891 case 'G': //"&GIF"
7892 SnapshotFormat=1;
7893 break;
7894
7895 case 'J': //"&JPG"
7896 SnapshotFormat=2;
7897 break;
7898
7899 case 'P': //"&PNG"
7900 SnapshotFormat=3;
7901 break;
7902
7903 case 'C': //"PC&X"
7904 SnapshotFormat=4;
7905 break;
7906
7907 case 'T': //"&TGA"
7908 SnapshotFormat=5;
7909 break;
7910
7911 case 'L': //"&LBM"
7912 SnapshotFormat=6;
7913 break;
7914 }
7915 zc_set_config("zeldadx", "snapshot_format", SnapshotFormat);
7916
7917 snapshot_format_menu[SnapshotFormat].flags=D_SELECTED;
7918 return D_O_K;
7919 }
7920
7921
7922 43 void color_layer(RGB *src,RGB *dest,char r,char g,char b,char pos,int32_t from,int32_t to)
7923 {
7924 PALETTE tmp;
7925
7926
2/2
✓ Branch 0 taken 11008 times.
✓ Branch 1 taken 43 times.
11051 for(int32_t i=0; i<256; i++)
7927 {
7928 11008 tmp[i].r=r;
7929 11008 tmp[i].g=g;
7930 11008 tmp[i].b=b;
7931 11008 }
7932
7933 43 fade_interpolate(src,tmp,dest,pos,from,to);
7934 43 }
7935
7936 43 void system_pal()
7937 {
7938 43 is_sys_pal = true;
7939 static PALETTE pal;
7940 43 copy_pal((RGB*)datafile[PAL_GUI].dat, pal);
7941
7942 // set up the grayscale palette
7943
2/2
✓ Branch 0 taken 2752 times.
✓ Branch 1 taken 43 times.
2795 for(int32_t i=128; i<192; i++)
7944 {
7945 2752 pal[i].r = i-128;
7946 2752 pal[i].g = i-128;
7947 2752 pal[i].b = i-128;
7948 2752 }
7949 43 load_colorset(gui_colorset, pal, jwin_a5_colors);
7950
7951 43 color_layer(pal, pal, 24,16,16, 28, 128,191);
7952
7953
2/2
✓ Branch 0 taken 5504 times.
✓ Branch 1 taken 43 times.
5547 for(int32_t i=0; i<256; i+=2)
7954 {
7955 5504 int32_t v = (i>>3)+2;
7956 5504 int32_t c = (i>>3)+192;
7957 5504 pal[c] = _RGB(v,v,v+(v>>1));
7958 /*
7959 if(i<240)
7960 {
7961 _allegro_hline(tmp_scr,0,i,319,c);
7962 _allegro_hline(tmp_scr,0,i+1,319,c);
7963 }
7964 */
7965 5504 }
7966
7967 // draw the vertical screen gradient
7968
2/2
✓ Branch 0 taken 10320 times.
✓ Branch 1 taken 43 times.
10363 for(int32_t i=0; i<240; ++i)
7969 {
7970 10320 _allegro_hline(tmp_scr,0,i,319,192+(i*31/239));
7971 10320 }
7972
7973 /*
7974 palrstart= 10*63/255; palrend=166*63/255;
7975 palgstart= 36*63/255; palgend=202*63/255;
7976 palbstart=106*63/255; palbend=240*63/255;
7977 paldivs=32;
7978 for(int32_t i=0; i<paldivs; i++)
7979 {
7980 pal[223-paldivs+1+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
7981 pal[223-paldivs+1+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
7982 pal[223-paldivs+1+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
7983 }
7984 */
7985 43 BITMAP *panorama = create_bitmap_ex(8,256,224);
7986 int32_t ts_height, ts_start;
7987
7988
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 43 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
43 if(tmpscr->flags3&fNOSUBSCR && !(tmpscr->flags3&fNOSUBSCROFFSET))
7989 {
7990 clear_to_color(panorama,0);
7991 blit(framebuf,panorama,0,playing_field_offset,0,28,256,224-passive_subscreen_height);
7992 ts_height=224-passive_subscreen_height;
7993 ts_start=28;
7994 }
7995 else
7996 {
7997 43 blit(framebuf,panorama,0,0,0,0,256,224);
7998 43 ts_height=224;
7999 43 ts_start=0;
8000 }
8001
8002 // gray scale the current frame
8003
2/2
✓ Branch 0 taken 9632 times.
✓ Branch 1 taken 43 times.
9675 for(int32_t y=0; y<ts_height; y++)
8004 {
8005
2/2
✓ Branch 0 taken 2465792 times.
✓ Branch 1 taken 9632 times.
2475424 for(int32_t x=0; x<256; x++)
8006 {
8007 2465792 int32_t c = panorama->line[y+ts_start][x];
8008
2/2
✓ Branch 0 taken 2459902 times.
✓ Branch 1 taken 5890 times.
2465792 int32_t gray = zc_min((RAMpal[c].r*42 + RAMpal[c].g*75 + RAMpal[c].b*14) >> 7, 63);
8009 2465792 tmp_scr->line[y+8+ts_start][x+32] = gray+128;
8010 2465792 }
8011 9632 }
8012
8013 43 destroy_bitmap(panorama);
8014
8015 // display everything
8016 43 vsync();
8017 43 hw_palette = &pal;
8018 43 update_hw_pal = true;
8019
8020 // sys_pal = pal;
8021 43 memcpy(sys_pal,pal,sizeof(pal));
8022 43 }
8023
8024 void system_pal2()
8025 {
8026 is_sys_pal = true;
8027 static PALETTE RAMpal2;
8028 copy_pal((RGB*)datafile[PAL_GUI].dat, RAMpal2);
8029
8030 /* Windows 2000 colors
8031 RAMpal2[dvc(1)] = _RGB( 0*63/255, 0*63/255, 0*63/255);
8032 RAMpal2[dvc(2)] = _RGB( 66*63/255, 65*63/255, 66*63/255);
8033 RAMpal2[dvc(3)] = _RGB(132*63/255, 130*63/255, 132*63/255);
8034 RAMpal2[dvc(4)] = _RGB(212*63/255, 208*63/255, 200*63/255);
8035 RAMpal2[dvc(5)] = _RGB(255*63/255, 255*63/255, 255*63/255);
8036 RAMpal2[dvc(6)] = _RGB(255*63/255, 255*63/255, 225*63/255);
8037 RAMpal2[dvc(7)] = _RGB(255*63/255, 225*63/255, 160*63/255);
8038 RAMpal2[dvc(8)] = _RGB( 0*63/255, 0*63/255, 80*63/255);
8039
8040 byte palrstart= 10*63/255, palrend=166*63/255,
8041 palgstart= 36*63/255, palgend=202*63/255,
8042 palbstart=106*63/255, palbend=240*63/255,
8043 paldivs=7;
8044 for(int32_t i=0; i<paldivs; i++)
8045 {
8046 RAMpal2[dvc(15-paldivs+1)+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8047 RAMpal2[dvc(15-paldivs+1)+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8048 RAMpal2[dvc(15-paldivs+1)+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8049 }
8050 */
8051
8052 /* Windows 98 colors
8053 RAMpal2[dvc(1)] = _RGB( 0*63/255, 0*63/255, 0*63/255);
8054 RAMpal2[dvc(2)] = _RGB(128*63/255, 128*63/255, 128*63/255);
8055 RAMpal2[dvc(3)] = _RGB(192*63/255, 192*63/255, 192*63/255);
8056 RAMpal2[dvc(4)] = _RGB(223*63/255, 223*63/255, 223*63/255);
8057 RAMpal2[dvc(5)] = _RGB(255*63/255, 255*63/255, 255*63/255);
8058 RAMpal2[dvc(6)] = _RGB(255*63/255, 255*63/255, 225*63/255);
8059 RAMpal2[dvc(7)] = _RGB(255*63/255, 225*63/255, 160*63/255);
8060 RAMpal2[dvc(8)] = _RGB( 0*63/255, 0*63/255, 80*63/255);
8061
8062 byte palrstart= 0*63/255, palrend=166*63/255,
8063 palgstart= 0*63/255, palgend=202*63/255,
8064 palbstart=128*63/255, palbend=240*63/255,
8065 paldivs=7;
8066 for(int32_t i=0; i<paldivs; i++)
8067 {
8068 RAMpal2[dvc(15-paldivs+1)+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8069 RAMpal2[dvc(15-paldivs+1)+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8070 RAMpal2[dvc(15-paldivs+1)+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8071 }
8072 */
8073
8074 /* Windows 99 colors
8075 RAMpal2[dvc(1)] = _RGB( 0*63/255, 0*63/255, 0*63/255);
8076 RAMpal2[dvc(2)] = _RGB( 64*63/255, 64*63/255, 64*63/255);
8077 RAMpal2[dvc(3)] = _RGB(128*63/255, 128*63/255, 128*63/255);
8078 RAMpal2[dvc(4)] = _RGB(192*63/255, 192*63/255, 192*63/255);
8079 RAMpal2[dvc(5)] = _RGB(223*63/255, 223*63/255, 223*63/255);
8080 RAMpal2[dvc(6)] = _RGB(255*63/255, 255*63/255, 255*63/255);
8081 RAMpal2[dvc(7)] = _RGB(255*63/255, 255*63/255, 225*63/255);
8082 RAMpal2[dvc(8)] = _RGB(255*63/255, 225*63/255, 160*63/255);
8083 RAMpal2[dvc(9)] = _RGB( 0*63/255, 0*63/255, 80*63/255);
8084
8085 byte palrstart= 0*63/255, palrend=166*63/255,
8086 palgstart= 0*63/255, palgend=202*63/255,
8087
8088 palbstart=128*63/255, palbend=240*63/255,
8089 paldivs=6;
8090 for(int32_t i=0; i<paldivs; i++)
8091 {
8092 RAMpal2[dvc(15-paldivs+1)+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8093 RAMpal2[dvc(15-paldivs+1)+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8094 RAMpal2[dvc(15-paldivs+1)+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8095 }
8096 */
8097
8098
8099
8100 RAMpal2[dvc(1)] = _RGB(0*63/255, 0*63/255, 0*63/255);
8101 RAMpal2[dvc(2)] = _RGB(64*63/255, 64*63/255, 64*63/255);
8102 RAMpal2[dvc(3)] = _RGB(128*63/255, 128*63/255, 128*63/255);
8103 RAMpal2[dvc(4)] = _RGB(192*63/255, 192*63/255, 192*63/255);
8104 RAMpal2[dvc(5)] = _RGB(223*63/255, 223*63/255, 223*63/255);
8105 RAMpal2[dvc(6)] = _RGB(255*63/255, 255*63/255, 255*63/255);
8106 RAMpal2[dvc(7)] = _RGB(255*63/255, 255*63/255, 225*63/255);
8107 RAMpal2[dvc(8)] = _RGB(255*63/255, 225*63/255, 160*63/255);
8108 RAMpal2[dvc(9)] = _RGB(0*63/255, 0*63/255, 80*63/255);
8109
8110 byte palrstart= 0*63/255, palrend=166*63/255,
8111 palgstart= 0*63/255, palgend=202*63/255,
8112 palbstart=128*63/255, palbend=240*63/255,
8113 paldivs=6;
8114
8115 for(int32_t i=0; i<paldivs; i++)
8116 {
8117 RAMpal2[dvc(15-paldivs+1)+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8118 RAMpal2[dvc(15-paldivs+1)+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8119 RAMpal2[dvc(15-paldivs+1)+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8120 }
8121
8122 gui_bg_color=jwin_pal[jcBOX];
8123 gui_fg_color=jwin_pal[jcBOXFG];
8124
8125 jwin_set_colors(jwin_pal);
8126
8127
8128 // set up the new palette
8129 for(int32_t i=128; i<192; i++)
8130 {
8131 RAMpal2[i].r = i-128;
8132 RAMpal2[i].g = i-128;
8133 RAMpal2[i].b = i-128;
8134 }
8135
8136 /*
8137 for(int32_t i=0; i<64; i++)
8138 {
8139 RAMpal2[128+i] = _RGB(i,i,i)1));
8140 }
8141 */
8142
8143 /*
8144
8145 pal[vc(1)] = _RGB(0x00,0x00,0x14);
8146 pal[vc(4)] = _RGB(0x36,0x36,0x36);
8147 pal[vc(6)] = _RGB(0x10,0x10,0x10);
8148 pal[vc(7)] = _RGB(0x20,0x20,0x20);
8149 pal[vc(9)] = _RGB(0x20,0x20,0x24);
8150 pal[vc(11)] = _RGB(0x30,0x30,0x30);
8151 pal[vc(14)] = _RGB(0x3F,0x38,0x28);
8152
8153 gui_fg_color=vc(14);
8154 gui_bg_color=vc(1);
8155
8156 jwin_set_colors(jwin_pal);
8157 */
8158
8159 // color_layer(RAMpal2, RAMpal2, 24,16,16, 28, 128,191);
8160
8161 // set up the colors for the vertical screen gradient
8162 for(int32_t i=0; i<256; i+=2)
8163 {
8164 int32_t v = (i>>3)+2;
8165 int32_t c = (i>>3)+192;
8166 RAMpal2[c] = _RGB(v,v,v+(v>>1));
8167
8168 /*
8169 if(i<240)
8170 {
8171 _allegro_hline(tmp_scr,0,i,319,c);
8172 _allegro_hline(tmp_scr,0,i+1,319,c);
8173 }
8174 */
8175 }
8176
8177 // hw_palette = &RAMpal;
8178 // update_hw_pal = true;
8179
8180 for(int32_t i=0; i<240; ++i)
8181 {
8182 _allegro_hline(tmp_scr,0,i,319,192+(i*31/239));
8183 }
8184
8185 /*
8186 byte palrstart= 10*63/255, palrend=166*63/255,
8187 palgstart= 36*63/255, palgend=202*63/255,
8188 palbstart=106*63/255, palbend=240*63/255,
8189 paldivs=32;
8190 for(int32_t i=0; i<paldivs; i++)
8191 {
8192 pal[223-paldivs+1+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8193 pal[223-paldivs+1+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8194 pal[223-paldivs+1+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8195 }
8196 */
8197 BITMAP *panorama = create_bitmap_ex(8,256,224);
8198 int32_t ts_height, ts_start;
8199
8200 if(tmpscr->flags3&fNOSUBSCR && !(tmpscr->flags3&fNOSUBSCROFFSET))
8201 {
8202 clear_to_color(panorama,0);
8203 blit(framebuf,panorama,0,playing_field_offset,0,28,256,224-passive_subscreen_height);
8204 ts_height=224-passive_subscreen_height;
8205 ts_start=28;
8206 }
8207 else
8208 {
8209 blit(framebuf,panorama,0,0,0,0,256,224);
8210 ts_height=224;
8211 ts_start=0;
8212 }
8213
8214 // gray scale the current frame
8215 for(int32_t y=0; y<ts_height; y++)
8216 {
8217 for(int32_t x=0; x<256; x++)
8218 {
8219 int32_t c = panorama->line[y+ts_start][x];
8220 int32_t gray = zc_min((RAMpal2[c].r*42 + RAMpal2[c].g*75 + RAMpal2[c].b*14) >> 7, 63);
8221 tmp_scr->line[y+8+ts_start][x+32] = gray+128;
8222 }
8223 }
8224
8225 destroy_bitmap(panorama);
8226
8227 // display everything
8228 vsync();
8229 hw_palette = &RAMpal2;
8230 update_hw_pal = true;
8231
8232 blit(tmp_scr,screen,0,0,scrx,scry,320,240);
8233
8234 // sys_pal = pal;
8235 memcpy(sys_pal,RAMpal2,sizeof(RAMpal2));
8236 }
8237
8238 static uint32_t entered_sys_pal = 0;
8239 14 void enter_sys_pal()
8240 {
8241
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(is_sys_pal)
8242 {
8243 if(entered_sys_pal)
8244 ++entered_sys_pal;
8245 return;
8246 }
8247 14 system_pal();
8248 14 ++entered_sys_pal;
8249 14 }
8250 14 void exit_sys_pal()
8251 {
8252
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(entered_sys_pal)
8253 {
8254
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(!--entered_sys_pal)
8255 {
8256 14 game_pal();
8257 14 }
8258 14 }
8259 14 }
8260
8261 void switch_out_callback()
8262 {
8263 if (pause_in_background)
8264 {
8265 callback_switchin = 3;
8266 return;
8267 }
8268
8269 #ifdef _WIN32
8270 if(midi_patch_fix==0 || currmidi==-1)
8271 return;
8272
8273
8274 paused_midi_pos = midi_pos;
8275 zc_stop_midi();
8276 midi_paused=true;
8277 midi_suspended = midissuspHALTED;
8278 #endif
8279 }
8280
8281 void switch_in_callback()
8282 {
8283 if(pause_in_background)
8284 {
8285 return;
8286 }
8287
8288 #ifdef _WIN32
8289 if(midi_patch_fix==0 || currmidi==-1)
8290 return;
8291
8292 else
8293 {
8294 callback_switchin = 1;
8295 midi_suspended = midissuspRESUME;
8296 }
8297 #endif
8298 }
8299
8300 257 void game_pal()
8301 {
8302 257 is_sys_pal = false;
8303 257 entered_sys_pal = 0;
8304 257 clear_to_color(screen,BLACK);
8305 257 hw_palette = &RAMpal;
8306 257 update_hw_pal = true;
8307 257 }
8308
8309 static char bar_str[] = "";
8310
8311 14 void music_pause()
8312 {
8313 //al_pause_duh(tmplayer);
8314 14 zcmusic_pause(zcmusic, ZCM_PAUSE);
8315 14 zc_midi_pause();
8316 14 midi_paused=true;
8317 14 }
8318
8319 void music_resume()
8320 {
8321 //al_resume_duh(tmplayer);
8322 zcmusic_pause(zcmusic, ZCM_RESUME);
8323 zc_midi_resume();
8324 midi_paused=false;
8325 }
8326
8327 5320 void music_stop()
8328 {
8329 //al_stop_duh(tmplayer);
8330 //unload_duh(tmusic);
8331 //tmusic=NULL;
8332 //tmplayer=NULL;
8333 5320 zcmusic_stop(zcmusic);
8334 5320 zcmusic_unload_file(zcmusic);
8335 5320 zc_stop_midi();
8336 5320 midi_paused=false;
8337 5320 currmidi=-1;
8338 5320 }
8339
8340 void System()
8341 {
8342 mouse_down=gui_mouse_b();
8343 music_pause();
8344 pause_all_sfx();
8345 MenuOpen = true;
8346 system_pal();
8347 // FONT *oldfont=font;
8348 // font=tfont;
8349
8350 misc_menu[2].flags =(isFullScreen()==1)?D_SELECTED:0;
8351 misc_menu[3].flags =(isFullScreen()==1)?D_DISABLED:0;
8352
8353 game_menu[2].flags = getsaveslot() > -1 ? 0 : D_DISABLED;
8354 #if DEVLEVEL > 1
8355 dev_menu[dv_setcheat].flags = Playing ? 0 : D_DISABLED;
8356 #endif
8357 game_menu[3].flags =
8358 misc_menu[5].flags = Playing ? 0 : D_DISABLED;
8359 misc_menu[7].flags = !Playing ? 0 : D_DISABLED;
8360 fixes_menu[0].flags = (midi_patch_fix)?D_SELECTED:0;
8361 clear_keybuf();
8362 show_mouse(screen);
8363
8364 DIALOG_PLAYER *p;
8365
8366 clear_bitmap(menu_bmp);
8367 oldscreen = screen;
8368 screen = menu_bmp;
8369
8370 if(!Playing || (!zcheats.flags && !get_debug() && DEVLEVEL < 2 && !zqtesting_mode))
8371 {
8372 p = init_dialog(system_dlg2,-1);
8373 }
8374 else
8375 {
8376 p = init_dialog(system_dlg,-1);
8377 }
8378
8379 // drop the menu on startup if menu button pressed
8380 if(joybtn(Mbtn)||zc_getrawkey(KEY_ESC))
8381 simulate_keypress(KEY_G << 8);
8382
8383 do
8384 {
8385 if(close_button_quit)
8386 {
8387 close_button_quit = false;
8388 f_Quit(qEXIT);
8389 if(Quit) break;
8390 }
8391 rest(17);
8392
8393 if(mouse_down && !gui_mouse_b())
8394 mouse_down=0;
8395
8396 title_menu[0].flags = (title_version==0) ? D_SELECTED : 0;
8397 title_menu[1].flags = (title_version==1) ? D_SELECTED : 0;
8398 title_menu[2].flags = (title_version==2) ? D_SELECTED : 0;
8399
8400 settings_menu[1].flags = replay_is_replaying() ? D_DISABLED : 0;
8401 settings_menu[5].flags = Throttlefps?D_SELECTED:0;
8402 settings_menu[6].flags = ShowFPS?D_SELECTED:0;
8403 settings_menu[7].flags = TransLayers?D_SELECTED:0;
8404 settings_menu[8].flags = NESquit?D_SELECTED:0;
8405 settings_menu[9].flags = ClickToFreeze?D_SELECTED:0;
8406 settings_menu[10].flags = SaveDragResize?D_SELECTED:0;
8407 settings_menu[11].flags = DragAspect?D_SELECTED:0;
8408 settings_menu[12].flags = SaveWinPos?D_SELECTED:0;
8409 settings_menu[13].flags = volkeys?D_SELECTED:0;
8410 //Epilepsy Prevention
8411 settings_menu[16].flags = (epilepsyFlashReduction) ? D_SELECTED : 0;
8412
8413 name_entry_mode_menu[0].flags = (NameEntryMode==0)?D_SELECTED:0;
8414 name_entry_mode_menu[1].flags = (NameEntryMode==1)?D_SELECTED:0;
8415 name_entry_mode_menu[2].flags = (NameEntryMode==2)?D_SELECTED:0;
8416
8417 misc_menu[12].flags =(zasm_debugger)?D_SELECTED:0;
8418 misc_menu[13].flags =(zscript_debugger)?D_SELECTED:0;
8419 misc_menu[14].flags =(clearConsoleOnReload)?D_SELECTED:0;
8420 misc_menu[15].flags =(clearConsoleOnLoad)?D_SELECTED:0;
8421
8422 the_player_menu[2].flags = replay_is_replaying() ? D_DISABLED : 0;
8423 cheat_menu[0].flags = 0;
8424 refill_menu[4].flags = get_bit(quest_rules, qr_TRUEARROWS) ? 0 : D_DISABLED;
8425 cheat_menu[1].text = (cheat >= 1) || get_debug() ? bar_str : NULL;
8426 cheat_menu[3].text = (cheat >= 2) || get_debug() ? bar_str : NULL;
8427 cheat_menu[8].text = (cheat >= 3) || get_debug() ? bar_str : NULL;
8428 cheat_menu[10].text = (cheat >= 4) || get_debug() ? bar_str : NULL;
8429 cheat_menu[4].flags = getClock() ? D_SELECTED : 0;
8430 cheat_menu[11].flags = toogam ? D_SELECTED : 0;
8431 cheat_menu[12].flags = ignoreSideview ? D_SELECTED : 0;
8432 cheat_menu[13].flags = gofast ? D_SELECTED : 0;
8433
8434 show_menu[0].flags = show_layer_0 ? D_SELECTED : 0;
8435 show_menu[1].flags = show_layer_1 ? D_SELECTED : 0;
8436 show_menu[2].flags = show_layer_2 ? D_SELECTED : 0;
8437 show_menu[3].flags = show_layer_3 ? D_SELECTED : 0;
8438 show_menu[4].flags = show_layer_4 ? D_SELECTED : 0;
8439 show_menu[5].flags = show_layer_5 ? D_SELECTED : 0;
8440 show_menu[6].flags = show_layer_6 ? D_SELECTED : 0;
8441 show_menu[7].flags = show_layer_over ? D_SELECTED : 0;
8442 show_menu[8].flags = show_layer_push ? D_SELECTED : 0;
8443 show_menu[9].flags = show_sprites ? D_SELECTED : 0;
8444 show_menu[10].flags = show_ffcs ? D_SELECTED : 0;
8445 show_menu[12].flags = show_walkflags ? D_SELECTED : 0;
8446 show_menu[13].flags = show_ff_scripts ? D_SELECTED : 0;
8447 show_menu[14].flags = show_hitboxes ? D_SELECTED : 0;
8448 show_menu[15].flags = show_effectflags ? D_SELECTED : 0;
8449
8450 settings_menu[14].flags = heart_beep ? D_SELECTED : 0;
8451 settings_menu[15].flags = use_save_indicator ? D_SELECTED : 0;
8452
8453 replay_menu[0].text = zc_get_config("zeldadx", "replay_new_saves", false) ?
8454 (char *)"Disable recording new saves" :
8455 (char *)"Enable recording new saves";
8456 replay_menu[1].flags = replay_is_active() ? 0 : D_DISABLED;
8457 replay_menu[1].text = replay_get_mode() == ReplayMode::Record ?
8458 (char *)"Stop recording" :
8459 (char *)"Stop replaying";
8460 replay_menu[5].flags = replay_get_mode() == ReplayMode::Record ? 0 : D_DISABLED;
8461 replay_menu[6].text = replay_is_snapshot_all_frames() ?
8462 (char *)"Disable snapshot all frames" :
8463 (char *)"Enable snapshot all frames";
8464
8465 reset_snapshot_format_menu();
8466 snapshot_format_menu[SnapshotFormat].flags = D_SELECTED;
8467
8468 if(debug_enabled)
8469 {
8470 settings_menu[19].flags = get_debug() ? D_SELECTED : 0;
8471 }
8472
8473 if(gui_mouse_b() && !mouse_down)
8474 break;
8475
8476 // press menu to drop the menu
8477 if(rMbtn())
8478 simulate_keypress(KEY_G << 8);
8479
8480 if(input_idle(true) > after_time())
8481 // run Screeen Saver
8482 {
8483 // Screen saver enabled for now.
8484 clear_keybuf();
8485 scare_mouse();
8486 Matrix(ss_speed, ss_density, 0);
8487 system_pal();
8488 unscare_mouse();
8489 broadcast_dialog_message(MSG_DRAW, 0);
8490 }
8491
8492 update_hw_screen();
8493 }
8494 while(update_dialog(p));
8495
8496 screen = oldscreen;
8497
8498 // font=oldfont;
8499 mouse_down=gui_mouse_b();
8500 shutdown_dialog(p);
8501 show_mouse(NULL);
8502 MenuOpen = false;
8503 if(Quit)
8504 {
8505 kill_sfx();
8506 music_stop();
8507 update_hw_screen();
8508 }
8509 else
8510 {
8511 game_pal();
8512 music_resume();
8513 resume_all_sfx();
8514
8515 if(rc)
8516 ringcolor(false);
8517 }
8518
8519 eat_buttons();
8520
8521 rc=false;
8522 clear_keybuf();
8523 // text_mode(0);
8524 }
8525
8526 29 void fix_dialogs()
8527 {
8528 29 jwin_center_dialog(about_dlg);
8529 29 jwin_center_dialog(gamepad_dlg);
8530 29 jwin_center_dialog(credits_dlg);
8531 29 jwin_center_dialog(gamemode_dlg);
8532 29 jwin_center_dialog(getnum_dlg);
8533 29 jwin_center_dialog(goto_dlg);
8534 29 jwin_center_dialog(keyboard_control_dlg);
8535 29 jwin_center_dialog(midi_dlg);
8536 29 jwin_center_dialog(quest_dlg);
8537 29 jwin_center_dialog(scrsaver_dlg);
8538 29 jwin_center_dialog(sound_dlg);
8539 29 jwin_center_dialog(triforce_dlg);
8540
8541 // digi_dp[1] += scrx;
8542 // digi_dp[2] += scry;
8543 // midi_dp[1] += scrx;
8544 // midi_dp[2] += scry;
8545 // pan_dp[1] += scrx;
8546 // pan_dp[2] += scry;
8547 // emus_dp[1] += scrx;
8548 // emus_dp[2] += scry;
8549 // buf_dp[1] += scrx;
8550 // buf_dp[2] += scry;
8551 // sfx_dp[1] += scrx;
8552 // sfx_dp[2] += scry;
8553 29 }
8554
8555 /*****************************/
8556 /**** Custom Sound System ****/
8557 /*****************************/
8558
8559 2295 INLINE int32_t mixvol(int32_t v1,int32_t v2)
8560 {
8561
3/4
✓ Branch 0 taken 2061 times.
✓ Branch 1 taken 234 times.
✓ Branch 2 taken 2295 times.
✗ Branch 3 not taken.
2295 return (zc_min(v1,255)*zc_min(v2,255)) >> 8;
8562 }
8563
8564 // Run an NSF, or a MIDI if the NSF is missing somehow.
8565 83 bool try_zcmusic(char *filename, int32_t track, int32_t midi)
8566 {
8567 83 ZCMUSIC *newzcmusic = zcmusic_load_for_quest(filename, qstpath);
8568
8569 // Found it
8570
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 35 times.
83 if(newzcmusic!=NULL)
8571 {
8572 48 zcmusic_stop(zcmusic);
8573 48 zcmusic_unload_file(zcmusic);
8574 48 zc_stop_midi();
8575
8576 48 zcmusic=newzcmusic;
8577 48 zcmusic_play(zcmusic, emusic_volume);
8578
8579
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if(track>0)
8580 48 zcmusic_change_track(zcmusic,track);
8581
8582 48 return true;
8583 }
8584
8585 // Not found, play MIDI - unless this was called by a script (yay, magic numbers)
8586
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 else if(midi>-1000)
8587 jukebox(midi);
8588
8589 35 return false;
8590 83 }
8591
8592 bool try_zcmusic_ex(char *filename, int32_t track, int32_t midi)
8593 {
8594 ZCMUSIC *newzcmusic = zcmusic_load_for_quest(filename, qstpath);
8595 // Found it
8596 if(newzcmusic!=NULL)
8597 {
8598 zcmusic_stop(zcmusic);
8599 zcmusic_unload_file(zcmusic);
8600 zc_stop_midi();
8601
8602 zcmusic=newzcmusic;
8603 zcmusic_play(zcmusic, emusic_volume);
8604
8605 if(track>0)
8606 zcmusic_change_track(zcmusic,track);
8607
8608 return true;
8609 }
8610
8611 // Not found, play MIDI - unless this was called by a script (yay, magic numbers)
8612 else if(midi>-1000)
8613 jukebox(midi);
8614
8615 return false;
8616 }
8617
8618 int32_t get_zcmusicpos()
8619 {
8620 int32_t debugtracething = zcmusic_get_curpos(zcmusic);
8621 return debugtracething;
8622 return 0;
8623 }
8624
8625 void set_zcmusicpos(int32_t position)
8626 {
8627 zcmusic_set_curpos(zcmusic, position);
8628 }
8629
8630 void set_zcmusicspeed(int32_t speed)
8631 {
8632 int32_t newspeed = vbound(speed, 0, 10000);
8633 zcmusic_set_speed(zcmusic, newspeed);
8634 }
8635
8636 1133 void jukebox(int32_t index,int32_t loop)
8637 {
8638 1133 music_stop();
8639
8640
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1133 times.
1133 if(index<0) index=MAXMIDIS-1;
8641
8642
1/2
✓ Branch 0 taken 1133 times.
✗ Branch 1 not taken.
1133 if(index>=MAXMIDIS) index=0;
8643
8644 1133 music_stop();
8645
8646 // Allegro's DIGMID driver (the one normally used on on Linux) gets
8647 // stuck notes when a song stops. This fixes it.
8648
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1133 times.
1133 if(strcmp(midi_driver->name, "DIGMID")==0)
8649 zc_set_volume(0, 0);
8650
8651 1133 zc_set_volume(-1, mixvol(tunes[index].volume,midi_volume>>1));
8652 1133 zc_play_midi((MIDI*)tunes[index].data,loop);
8653
8654
2/2
✓ Branch 0 taken 756 times.
✓ Branch 1 taken 377 times.
1133 if(tunes[index].start>0)
8655 377 zc_midi_seek(tunes[index].start);
8656
8657 1133 midi_loop_start = tunes[index].loop_start;
8658 1133 midi_loop_end = tunes[index].loop_end;
8659
8660 1133 currmidi=index;
8661 1133 master_volume(digi_volume,midi_volume);
8662 1133 midi_paused=false;
8663 1133 }
8664
8665 8589 void jukebox(int32_t index)
8666 {
8667
1/2
✓ Branch 0 taken 8589 times.
✗ Branch 1 not taken.
8589 if(index<0) index=MAXMIDIS-1;
8668
8669
1/2
✓ Branch 0 taken 8589 times.
✗ Branch 1 not taken.
8589 if(index>=MAXMIDIS) index=0;
8670
8671 // do nothing if it's already playing
8672
3/4
✓ Branch 0 taken 7456 times.
✓ Branch 1 taken 1133 times.
✓ Branch 2 taken 7456 times.
✗ Branch 3 not taken.
8589 if(index==currmidi && midi_pos>=0)
8673 {
8674 7456 midi_paused=false;
8675 7456 return;
8676 }
8677
8678 1133 jukebox(index,tunes[index].loop);
8679 8589 }
8680
8681 9829 void play_DmapMusic()
8682 {
8683 static char tfile[2048];
8684 static int32_t ttrack=0;
8685 9829 bool domidi=false;
8686
8687
2/2
✓ Branch 0 taken 1330 times.
✓ Branch 1 taken 8499 times.
9829 if(DMaps[currdmap].tmusic[0]!=0)
8688 {
8689
3/4
✓ Branch 0 taken 385 times.
✓ Branch 1 taken 945 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 385 times.
1715 if(zcmusic==NULL ||
8690
1/2
✓ Branch 0 taken 385 times.
✗ Branch 1 not taken.
385 strcmp(zcmusic->filename,DMaps[currdmap].tmusic)!=0 ||
8691
1/2
✓ Branch 0 taken 385 times.
✗ Branch 1 not taken.
385 (zcmusic->type==ZCMF_GME && zcmusic->track != DMaps[currdmap].tmusictrack))
8692 {
8693
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 945 times.
945 if(zcmusic != NULL)
8694 {
8695 zcmusic_stop(zcmusic);
8696 zcmusic_unload_file(zcmusic);
8697 zcmusic = NULL;
8698 }
8699
8700 945 zcmusic = zcmusic_load_for_quest(DMaps[currdmap].tmusic, qstpath);
8701
8702
2/2
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 859 times.
945 if(zcmusic!=NULL)
8703 {
8704 86 zc_stop_midi();
8705 86 strcpy(tfile,DMaps[currdmap].tmusic);
8706 86 zcmusic_play(zcmusic, emusic_volume);
8707 86 int32_t temptracks=0;
8708 86 temptracks=zcmusic_get_tracks(zcmusic);
8709
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 86 times.
86 temptracks=(temptracks<2)?1:temptracks;
8710 86 ttrack = vbound(DMaps[currdmap].tmusictrack,0,temptracks-1);
8711 86 zcmusic_change_track(zcmusic,ttrack);
8712 86 }
8713 else
8714 {
8715 859 tfile[0] = 0;
8716 859 domidi=true;
8717 }
8718 945 }
8719 1330 }
8720 else
8721 {
8722 8499 domidi=true;
8723 }
8724
8725
2/2
✓ Branch 0 taken 471 times.
✓ Branch 1 taken 9358 times.
9829 if(domidi)
8726 {
8727 9358 int32_t m=DMaps[currdmap].midi;
8728
8729
3/4
✓ Branch 0 taken 9243 times.
✓ Branch 1 taken 105 times.
✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
9358 switch(m)
8730 {
8731 case 1:
8732 105 jukebox(ZC_MIDI_OVERWORLD);
8733 105 break;
8734
8735 case 2:
8736 10 jukebox(ZC_MIDI_DUNGEON);
8737 10 break;
8738
8739 case 3:
8740 jukebox(ZC_MIDI_LEVEL9);
8741 break;
8742
8743 default:
8744
3/4
✓ Branch 0 taken 8329 times.
✓ Branch 1 taken 914 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8329 times.
9243 if(m>=4 && m<4+MAXCUSTOMMIDIS)
8745 8329 jukebox(m+MIDIOFFSET_DMAP);
8746 else
8747 914 music_stop();
8748 9243 }
8749 9358 }
8750 9829 }
8751
8752 9866 void playLevelMusic()
8753 {
8754 9866 int32_t m=tmpscr->screen_midi;
8755
8756
3/6
✓ Branch 0 taken 9813 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 41 times.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
9866 switch(m)
8757 {
8758 case -2:
8759 12 music_stop();
8760 12 break;
8761
8762 case -1:
8763 9813 play_DmapMusic();
8764 9813 break;
8765
8766 case 1:
8767 jukebox(ZC_MIDI_OVERWORLD);
8768 break;
8769
8770 case 2:
8771 jukebox(ZC_MIDI_DUNGEON);
8772 break;
8773
8774 case 3:
8775 jukebox(ZC_MIDI_LEVEL9);
8776 break;
8777
8778 default:
8779
2/4
✓ Branch 0 taken 41 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 41 times.
✗ Branch 3 not taken.
41 if(m>=4 && m<4+MAXCUSTOMMIDIS)
8780 41 jukebox(m+MIDIOFFSET_MAPSCR);
8781 else
8782 music_stop();
8783 41 }
8784 9866 }
8785
8786 1162 void master_volume(int32_t dv,int32_t mv)
8787 {
8788
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1162 times.
✓ Branch 2 taken 1162 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1162 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1162 times.
✗ Branch 7 not taken.
1162 if(dv>=0) digi_volume=zc_max(zc_min(dv,255),0);
8789
8790
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1162 times.
✓ Branch 2 taken 1162 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1162 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1162 times.
✗ Branch 7 not taken.
1162 if(mv>=0) midi_volume=zc_max(zc_min(mv,255),0);
8791
8792
6/6
✓ Branch 0 taken 1132 times.
✓ Branch 1 taken 30 times.
✓ Branch 2 taken 1160 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 1130 times.
✓ Branch 5 taken 30 times.
1162 int32_t i = zc_min(zc_max(currmidi,0),MAXMIDIS-1);
8793 1162 zc_set_volume(digi_volume,mixvol(tunes[i].volume,midi_volume));
8794 1162 }
8795
8796 /*****************/
8797 /***** SFX *****/
8798 /*****************/
8799
8800 // array of voices, one for each sfx sample in the data file
8801 // 0+ = voice #
8802 // -1 = voice not allocated
8803 29 void Z_init_sound()
8804 {
8805
2/2
✓ Branch 0 taken 7424 times.
✓ Branch 1 taken 29 times.
7453 for(int32_t i=0; i<WAV_COUNT; i++)
8806 7424 sfx_voice[i]=-1;
8807
8808
2/2
✓ Branch 0 taken 203 times.
✓ Branch 1 taken 29 times.
232 for(int32_t i=0; i<ZC_MIDI_COUNT; i++)
8809 203 tunes[i].data = (MIDI*)mididata[i].dat;
8810
8811
2/2
✓ Branch 0 taken 7308 times.
✓ Branch 1 taken 29 times.
7337 for(int32_t j=0; j<MAXCUSTOMMIDIS; j++)
8812 7308 tunes[ZC_MIDI_COUNT+j].data=NULL;
8813
8814 29 master_volume(digi_volume,midi_volume);
8815 29 }
8816
8817 // returns number of voices currently allocated
8818 int32_t sfx_count()
8819 {
8820 int32_t c=0;
8821
8822 for(int32_t i=0; i<WAV_COUNT; i++)
8823 if(sfx_voice[i]!=-1)
8824 ++c;
8825
8826 return c;
8827 }
8828
8829 // clean up finished samples
8830 6480723 void sfx_cleanup()
8831 {
8832
2/2
✓ Branch 0 taken 1659065088 times.
✓ Branch 1 taken 6480723 times.
1665545811 for(int32_t i=0; i<WAV_COUNT; i++)
8833
3/4
✓ Branch 0 taken 560755 times.
✓ Branch 1 taken 1658504333 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 560755 times.
1659625843 if(sfx_voice[i]!=-1 && voice_get_position(sfx_voice[i])<0)
8834 {
8835 560755 deallocate_voice(sfx_voice[i]);
8836 560755 sfx_voice[i]=-1;
8837 560755 }
8838 6480723 }
8839
8840 // allocates a voice for the sample "wav_index" (index into zelda.dat)
8841 // if a voice is already allocated (and/or playing), then it just returns true
8842 // Returns true: voice is allocated
8843 // false: unsuccessful
8844 838762 bool sfx_init(int32_t index)
8845 {
8846 // check index
8847
3/4
✓ Branch 0 taken 620761 times.
✓ Branch 1 taken 218001 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 620761 times.
838762 if(index<=0 || index>=WAV_COUNT)
8848 218001 return false;
8849
8850
2/2
✓ Branch 0 taken 59980 times.
✓ Branch 1 taken 560781 times.
620761 if(sfx_voice[index]==-1)
8851 {
8852
2/2
✓ Branch 0 taken 110294 times.
✓ Branch 1 taken 450487 times.
560781 if(sfxdat)
8853 {
8854
1/2
✓ Branch 0 taken 110294 times.
✗ Branch 1 not taken.
110294 if(index<Z35)
8855 {
8856 110294 sfx_voice[index]=allocate_voice((SAMPLE*)sfxdata[index].dat);
8857 110294 }
8858 else
8859 {
8860 sfx_voice[index]=allocate_voice((SAMPLE*)sfxdata[Z35].dat);
8861 }
8862 110294 }
8863 else
8864 {
8865 450487 sfx_voice[index]=allocate_voice(&customsfxdata[index]);
8866 }
8867
8868 560781 voice_set_volume(sfx_voice[index], sfx_volume);
8869 560781 }
8870
8871 620761 return sfx_voice[index] != -1;
8872 838762 }
8873
8874 // plays an sfx sample
8875 732250 void sfx(int32_t index,int32_t pan,bool loop, bool restart)
8876 {
8877
2/2
✓ Branch 0 taken 550996 times.
✓ Branch 1 taken 181254 times.
732250 if(!sfx_init(index))
8878 181254 return;
8879
8880 550996 voice_set_playmode(sfx_voice[index],loop?PLAYMODE_LOOP:PLAYMODE_PLAY);
8881 550996 voice_set_pan(sfx_voice[index],pan);
8882
8883 550996 int32_t pos = voice_get_position(sfx_voice[index]);
8884
8885
2/2
✓ Branch 0 taken 259936 times.
✓ Branch 1 taken 291060 times.
550996 if(restart) voice_set_position(sfx_voice[index],0);
8886
8887
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 550996 times.
550996 if(pos<=0)
8888 550996 voice_start(sfx_voice[index]);
8889
8890
3/4
✓ Branch 0 taken 291060 times.
✓ Branch 1 taken 259936 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 291060 times.
550996 if (restart && replay_is_debug())
8891
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 291060 times.
291060 replay_step_comment(fmt::format("sfx {}", sfx_string[index]));
8892 732250 }
8893
8894 // true if sfx is allocated
8895 32243 bool sfx_allocated(int32_t index)
8896 {
8897
3/4
✓ Branch 0 taken 9403 times.
✓ Branch 1 taken 22840 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9403 times.
32243 return (index>0 && index<WAV_COUNT && sfx_voice[index]!=-1);
8898 }
8899
8900 // start it (in loop mode) if it's not already playing,
8901 // otherwise adjust it to play in loop mode -DD
8902 106512 void cont_sfx(int32_t index)
8903 {
8904
2/2
✓ Branch 0 taken 36747 times.
✓ Branch 1 taken 69765 times.
106512 if(!sfx_init(index))
8905 {
8906 36747 return;
8907 }
8908
8909
1/2
✓ Branch 0 taken 69765 times.
✗ Branch 1 not taken.
69765 if(voice_get_position(sfx_voice[index])<=0)
8910 {
8911 69765 voice_set_position(sfx_voice[index],0);
8912 69765 voice_set_playmode(sfx_voice[index],PLAYMODE_LOOP);
8913 69765 voice_start(sfx_voice[index]);
8914 69765 }
8915 else
8916 {
8917 adjust_sfx(index, 128, true);
8918 }
8919 106512 }
8920
8921 // adjust parameters while playing
8922 3547 void adjust_sfx(int32_t index,int32_t pan,bool loop)
8923 {
8924
5/6
✓ Branch 0 taken 2124 times.
✓ Branch 1 taken 1423 times.
✓ Branch 2 taken 2124 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14 times.
✓ Branch 5 taken 2110 times.
3547 if(index<=0 || index>=WAV_COUNT || sfx_voice[index]==-1)
8925 3533 return;
8926
8927 14 voice_set_playmode(sfx_voice[index],loop?PLAYMODE_LOOP:PLAYMODE_PLAY);
8928 14 voice_set_pan(sfx_voice[index],pan);
8929 3547 }
8930
8931 // pauses a voice
8932 1468 void pause_sfx(int32_t index)
8933 {
8934
3/6
✓ Branch 0 taken 1468 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1468 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1468 times.
1468 if(index>0 && index<WAV_COUNT && sfx_voice[index]!=-1)
8935 voice_stop(sfx_voice[index]);
8936 1468 }
8937
8938 // resumes a voice
8939 637 void resume_sfx(int32_t index)
8940 {
8941
3/6
✓ Branch 0 taken 637 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 637 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 637 times.
637 if(index>0 && index<WAV_COUNT && sfx_voice[index]!=-1)
8942 voice_start(sfx_voice[index]);
8943 637 }
8944
8945 // pauses all active voices
8946 244 void pause_all_sfx()
8947 {
8948
2/2
✓ Branch 0 taken 62464 times.
✓ Branch 1 taken 244 times.
62708 for(int32_t i=0; i<WAV_COUNT; i++)
8949
2/2
✓ Branch 0 taken 62462 times.
✓ Branch 1 taken 2 times.
62466 if(sfx_voice[i]!=-1)
8950 2 voice_stop(sfx_voice[i]);
8951 244 }
8952
8953 // resumes all paused voices
8954 230 void resume_all_sfx()
8955 {
8956
2/2
✓ Branch 0 taken 58880 times.
✓ Branch 1 taken 230 times.
59110 for(int32_t i=0; i<WAV_COUNT; i++)
8957
1/2
✓ Branch 0 taken 58880 times.
✗ Branch 1 not taken.
58880 if(sfx_voice[i]!=-1)
8958 voice_start(sfx_voice[i]);
8959 230 }
8960
8961 // stops an sfx and deallocates the voice
8962 5203476 void stop_sfx(int32_t index)
8963 {
8964
3/4
✓ Branch 0 taken 5102116 times.
✓ Branch 1 taken 101360 times.
✓ Branch 2 taken 5102116 times.
✗ Branch 3 not taken.
5203476 if(index<=0 || index>=WAV_COUNT)
8965 101360 return;
8966
8967
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 5102103 times.
5102116 if(sfx_voice[index]!=-1)
8968 {
8969 13 deallocate_voice(sfx_voice[index]);
8970 13 sfx_voice[index]=-1;
8971 13 }
8972 5203476 }
8973
8974 // Stops SFX played by Hero's item of the given family
8975 131169 void stop_item_sfx(int32_t family)
8976 {
8977 131169 int32_t id=current_item_id(family);
8978
8979
2/2
✓ Branch 0 taken 130841 times.
✓ Branch 1 taken 328 times.
131169 if(id<0)
8980 130841 return;
8981
8982 328 stop_sfx(itemsbuf[id].usesound);
8983 131169 }
8984
8985 1802 void kill_sfx()
8986 {
8987
2/2
✓ Branch 0 taken 461312 times.
✓ Branch 1 taken 1802 times.
463114 for(int32_t i=0; i<WAV_COUNT; i++)
8988
2/2
✓ Branch 0 taken 461299 times.
✓ Branch 1 taken 13 times.
461325 if(sfx_voice[i]!=-1)
8989 {
8990 13 deallocate_voice(sfx_voice[i]);
8991 13 sfx_voice[i]=-1;
8992 13 }
8993 1802 }
8994
8995 504198 int32_t pan(int32_t x)
8996 {
8997
1/4
✓ Branch 0 taken 504198 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
504198 switch(pan_style)
8998 {
8999 case 0:
9000 return 128;
9001
9002 case 1:
9003 504198 return vbound((x>>1)+68,0,255);
9004
9005 case 2:
9006 return vbound(((x*3)>>2)+36,0,255);
9007 }
9008
9009 return vbound(x,0,255);
9010 504198 }
9011
9012 /*******************************/
9013 /******* Input Handlers ********/
9014 /*******************************/
9015
9016 16584516 bool joybtn(int32_t b)
9017 {
9018
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16584516 times.
16584516 if(b == 0)
9019 return false;
9020
9021 16584516 return joy[joystick_index].button[b-1].b !=0;
9022 16584516 }
9023
9024 const char* joybtn_name(int32_t b)
9025 {
9026 if(b == 0)
9027 return "";
9028
9029 return joy[joystick_index].button[b-1].name;
9030 }
9031
9032 int32_t next_press_key();
9033
9034 int32_t next_press_btn()
9035 {
9036 clear_keybuf();
9037 /*bool b[joy[joystick_index].num_buttons+1];
9038
9039 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
9040 b[i]=joybtn(i);*/
9041
9042 //first, we need to wait until they're pressing no buttons
9043 for(;;)
9044 {
9045 if(keypressed())
9046 {
9047 switch(readkey()>>8)
9048 {
9049 case KEY_ESC:
9050 return -1;
9051
9052 case KEY_SPACE:
9053 return 0;
9054 }
9055 }
9056
9057 poll_joystick();
9058 bool done = true;
9059
9060 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
9061 {
9062 if(joybtn(i)) done = false;
9063 }
9064
9065 if(done) break;
9066 rest(1);
9067 }
9068
9069 //now, we need to wait for them to press any button
9070 for(;;)
9071 {
9072 if(keypressed())
9073 {
9074 switch(readkey()>>8)
9075 {
9076 case KEY_ESC:
9077 return -1;
9078
9079 case KEY_SPACE:
9080 return 0;
9081 }
9082 }
9083
9084 poll_joystick();
9085
9086 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
9087 {
9088 if(joybtn(i)) return i;
9089 }
9090 rest(1);
9091 }
9092 }
9093
9094 134574253 static bool rButton(bool &btn, bool &flag, bool* rawbtn = nullptr)
9095 {
9096
2/2
✓ Branch 0 taken 129784481 times.
✓ Branch 1 taken 4789772 times.
134574253 bool ret = btn && !flag;
9097
2/2
✓ Branch 0 taken 117573131 times.
✓ Branch 1 taken 17001122 times.
134574253 flag = rawbtn ? *rawbtn : btn;
9098
9099 134574253 return ret;
9100 }
9101 1337132 static bool rButtonPeek(bool btn, bool flag)
9102 {
9103
2/2
✓ Branch 0 taken 1249424 times.
✓ Branch 1 taken 87708 times.
1337132 if(!btn)
9104 {
9105 1249424 return false;
9106 }
9107
2/2
✓ Branch 0 taken 14956 times.
✓ Branch 1 taken 72752 times.
87708 else if(!flag)
9108 {
9109 14956 return true;
9110 }
9111
9112 72752 return false;
9113 1337132 }
9114
9115 // Updated only by keyboard/gamepad.
9116 // If in replay mode, this is set directly by the replay system.
9117 // This should never be read from directly - use control_state instead.
9118 bool raw_control_state[ZC_CONTROL_STATES];
9119
9120 // Every call to load_control_state (pretty much every frame) resets this to be equal to raw_control_state.
9121 // This state can drift from raw_control_state if button states are "eaten" or overriden by a script. But that only
9122 // lasts until the next call to load_control_state.
9123 bool control_state[ZC_CONTROL_STATES];
9124 bool disable_control[ZC_CONTROL_STATES];
9125 bool drunk_toggle_state[11];
9126 bool disabledKeys[127];
9127 bool KeyInput[127];
9128 bool KeyPress[127];
9129
9130 bool key_current_frame[127];
9131 bool key_previous_frame[127];
9132
9133 static bool key_system[127];
9134 static bool key_system_previous[127];
9135 static bool key_system_press[127];
9136
9137 bool button_press[ZC_CONTROL_STATES];
9138 bool button_hold[ZC_CONTROL_STATES];
9139
9140 #define STICK_1_X joy[joystick_index].stick[js_stick_1_x_stick].axis[js_stick_1_x_axis]
9141 #define STICK_1_Y joy[joystick_index].stick[js_stick_1_y_stick].axis[js_stick_1_y_axis]
9142 #define STICK_2_X joy[joystick_index].stick[js_stick_2_x_stick].axis[js_stick_2_x_axis]
9143 #define STICK_2_Y joy[joystick_index].stick[js_stick_2_y_stick].axis[js_stick_2_y_axis]
9144 #define STICK_PRECISION 56 //define your own sensitivity
9145
9146 5438197 void load_control_state()
9147 {
9148 5438197 load_control_called_this_frame = true;
9149
9150
3/4
✓ Branch 0 taken 2566996 times.
✓ Branch 1 taken 2871201 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2566996 times.
5438197 if (replay_get_version() >= 8 && replay_get_version() < 11)
9151 {
9152
2/2
✓ Branch 0 taken 46205928 times.
✓ Branch 1 taken 2566996 times.
48772924 for (int i = 0; i < ZC_CONTROL_STATES; i++)
9153 46205928 down_control_states[i] = raw_control_state[i];
9154 2566996 }
9155
9156
1/2
✓ Branch 0 taken 5438197 times.
✗ Branch 1 not taken.
5438197 if (!replay_is_replaying())
9157 {
9158 raw_control_state[0]=zc_getrawkey(DUkey, true)||(analog_movement ? STICK_1_Y.d1 || STICK_1_Y.pos - js_stick_1_y_offset < -STICK_PRECISION : joybtn(DUbtn));
9159 raw_control_state[1]=zc_getrawkey(DDkey, true)||(analog_movement ? STICK_1_Y.d2 || STICK_1_Y.pos - js_stick_1_y_offset > STICK_PRECISION : joybtn(DDbtn));
9160 raw_control_state[2]=zc_getrawkey(DLkey, true)||(analog_movement ? STICK_1_X.d1 || STICK_1_X.pos - js_stick_1_x_offset < -STICK_PRECISION : joybtn(DLbtn));
9161 raw_control_state[3]=zc_getrawkey(DRkey, true)||(analog_movement ? STICK_1_X.d2 || STICK_1_X.pos - js_stick_1_x_offset > STICK_PRECISION : joybtn(DRbtn));
9162 raw_control_state[4]=zc_getrawkey(Akey, true)||joybtn(Abtn);
9163 raw_control_state[5]=zc_getrawkey(Bkey, true)||joybtn(Bbtn);
9164 raw_control_state[6]=zc_getrawkey(Skey, true)||joybtn(Sbtn);
9165 raw_control_state[7]=zc_getrawkey(Lkey, true)||joybtn(Lbtn);
9166 raw_control_state[8]=zc_getrawkey(Rkey, true)||joybtn(Rbtn);
9167 raw_control_state[9]=zc_getrawkey(Pkey, true)||joybtn(Pbtn);
9168 raw_control_state[10]=zc_getrawkey(Exkey1, true)||joybtn(Exbtn1);
9169 raw_control_state[11]=zc_getrawkey(Exkey2, true)||joybtn(Exbtn2);
9170 raw_control_state[12]=zc_getrawkey(Exkey3, true)||joybtn(Exbtn3);
9171 raw_control_state[13]=zc_getrawkey(Exkey4, true)||joybtn(Exbtn4);
9172
9173 if(num_joysticks != 0)
9174 {
9175 raw_control_state[14] = STICK_2_Y.pos - js_stick_2_y_offset < -STICK_PRECISION;
9176 raw_control_state[15] = STICK_2_Y.pos - js_stick_2_y_offset > STICK_PRECISION;
9177 raw_control_state[16] = STICK_2_X.pos - js_stick_2_x_offset < -STICK_PRECISION;
9178 raw_control_state[17] = STICK_2_X.pos - js_stick_2_x_offset > STICK_PRECISION;
9179 // zprint2("Detected %d joysticks... %d%d%d%d\n", num_joysticks, raw_control_state[14]?1:0, raw_control_state[15]?1:0, raw_control_state[16]?1:0, raw_control_state[17]?1:0);
9180 }
9181 else
9182 {
9183 raw_control_state[14] = false;
9184 raw_control_state[15] = false;
9185 raw_control_state[16] = false;
9186 raw_control_state[17] = false;
9187 // zprint2("Detected 0 joysticks... clearing inputaxis values.\n");
9188 }
9189 }
9190
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 5438194 times.
5438197 if (replay_is_active())
9191 {
9192
2/2
✓ Branch 0 taken 1015215 times.
✓ Branch 1 taken 4422979 times.
5438194 if (replay_get_version() < 3)
9193 1015215 replay_poll();
9194
3/4
✓ Branch 0 taken 4422979 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2661604 times.
✓ Branch 3 taken 1761375 times.
4422979 else if (replay_is_replaying() && replay_get_version() < 6)
9195 1761375 replay_peek_input();
9196
4/6
✓ Branch 0 taken 2661604 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2566996 times.
✓ Branch 3 taken 94608 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2566996 times.
2661604 else if (replay_is_replaying() && replay_get_version() >= 8 && replay_get_version() < 11)
9197 2566996 replay_peek_input();
9198
2/2
✓ Branch 0 taken 4320728 times.
✓ Branch 1 taken 1117466 times.
5438194 if (replay_get_version() == 8)
9199 1117466 update_keys();
9200 5438194 }
9201
9202 // Some test replay files were made before a serious input bug was fixed, so instead
9203 // of re-doing them or tossing them out, just check for that zplay version.
9204
3/4
✓ Branch 0 taken 5438191 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 121900 times.
✓ Branch 3 taken 5316291 times.
5438197 bool botched_input = replay_is_active() && replay_get_version() != 1 && replay_get_version() < 8;
9205
2/2
✓ Branch 0 taken 97887438 times.
✓ Branch 1 taken 5438191 times.
103325629 for (int i = 0; i < ZC_CONTROL_STATES; i++)
9206 {
9207 97887438 control_state[i] = raw_control_state[i];
9208
4/4
✓ Branch 0 taken 49487310 times.
✓ Branch 1 taken 48400128 times.
✓ Branch 2 taken 2410168 times.
✓ Branch 3 taken 47077142 times.
97887438 if (botched_input && !control_state[i])
9209 47077142 down_control_states[i] = false;
9210 97887438 }
9211
9212 5438191 button_press[0]=rButton(control_state[0],button_hold[0]);
9213 5438191 button_press[1]=rButton(control_state[1],button_hold[1]);
9214 5438191 button_press[2]=rButton(control_state[2],button_hold[2]);
9215 5438191 button_press[3]=rButton(control_state[3],button_hold[3]);
9216 5438191 button_press[4]=rButton(control_state[4],button_hold[4]);
9217 5438191 button_press[5]=rButton(control_state[5],button_hold[5]);
9218 5438191 button_press[6]=rButton(control_state[6],button_hold[6]);
9219 5438191 button_press[7]=rButton(control_state[7],button_hold[7]);
9220 5438191 button_press[8]=rButton(control_state[8],button_hold[8]);
9221 5438191 button_press[9]=rButton(control_state[9],button_hold[9]);
9222 5438191 button_press[10]=rButton(control_state[10],button_hold[10]);
9223 5438191 button_press[11]=rButton(control_state[11],button_hold[11]);
9224 5438191 button_press[12]=rButton(control_state[12],button_hold[12]);
9225 5438191 button_press[13]=rButton(control_state[13],button_hold[13]);
9226 5438191 button_press[14]=rButton(control_state[14],button_hold[14]);
9227 5438191 button_press[15]=rButton(control_state[15],button_hold[15]);
9228 5438191 button_press[16]=rButton(control_state[16],button_hold[16]);
9229 5438191 button_press[17]=rButton(control_state[17],button_hold[17]);
9230 5438191 }
9231
9232 // Returns true if any game key is pressed. This is needed because keypressed()
9233 // doesn't detect modifier keys and control_state[] can be modified by scripts.
9234 28178162 bool zc_key_pressed()
9235 //may also need to use zc_getrawkey
9236 {
9237
7/10
✓ Branch 0 taken 22800161 times.
✓ Branch 1 taken 5378001 times.
✓ Branch 2 taken 5378001 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5378001 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4533401 times.
✓ Branch 7 taken 4533401 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 1621032 times.
29799194 if((zc_getrawkey(DUkey, true)||(analog_movement ? STICK_1_Y.d1 || STICK_1_Y.pos - js_stick_1_y_offset< -STICK_PRECISION : joybtn(DUbtn))) ||
9238
4/6
✓ Branch 0 taken 4533401 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4533401 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3418530 times.
✓ Branch 5 taken 3418530 times.
4533401 (zc_getrawkey(DDkey, true)||(analog_movement ? STICK_1_Y.d2 || STICK_1_Y.pos - js_stick_1_y_offset > STICK_PRECISION : joybtn(DDbtn))) ||
9239
4/6
✓ Branch 0 taken 3418530 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3418530 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2176173 times.
✓ Branch 5 taken 2176173 times.
3418530 (zc_getrawkey(DLkey, true)||(analog_movement ? STICK_1_X.d1 || STICK_1_X.pos - js_stick_1_x_offset < -STICK_PRECISION : joybtn(DLbtn))) ||
9240
4/6
✓ Branch 0 taken 2176173 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2176173 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1838283 times.
✓ Branch 5 taken 1838283 times.
2176173 (zc_getrawkey(DRkey, true)||(analog_movement ? STICK_1_X.d2 || STICK_1_X.pos - js_stick_1_x_offset > STICK_PRECISION : joybtn(DRbtn))) ||
9241
1/2
✓ Branch 0 taken 1838283 times.
✗ Branch 1 not taken.
1838283 (zc_getrawkey(Akey, true)||joybtn(Abtn)) ||
9242
3/4
✓ Branch 0 taken 1736661 times.
✓ Branch 1 taken 101622 times.
✓ Branch 2 taken 1736661 times.
✗ Branch 3 not taken.
1838283 (zc_getrawkey(Bkey, true)||joybtn(Bbtn)) ||
9243
3/4
✓ Branch 0 taken 1646160 times.
✓ Branch 1 taken 90501 times.
✓ Branch 2 taken 1646160 times.
✗ Branch 3 not taken.
1736661 (zc_getrawkey(Skey, true)||joybtn(Sbtn)) ||
9244
3/4
✓ Branch 0 taken 1633476 times.
✓ Branch 1 taken 12684 times.
✓ Branch 2 taken 1633476 times.
✗ Branch 3 not taken.
1646160 (zc_getrawkey(Lkey, true)||joybtn(Lbtn)) ||
9245
3/4
✓ Branch 0 taken 1623117 times.
✓ Branch 1 taken 10359 times.
✓ Branch 2 taken 1623117 times.
✗ Branch 3 not taken.
1633476 (zc_getrawkey(Rkey, true)||joybtn(Rbtn)) ||
9246
3/4
✓ Branch 0 taken 1621864 times.
✓ Branch 1 taken 1253 times.
✓ Branch 2 taken 1621864 times.
✗ Branch 3 not taken.
1623117 (zc_getrawkey(Pkey, true)||joybtn(Pbtn)) ||
9247
3/4
✓ Branch 0 taken 1621821 times.
✓ Branch 1 taken 43 times.
✓ Branch 2 taken 1621821 times.
✗ Branch 3 not taken.
1621864 (zc_getrawkey(Exkey1, true)||joybtn(Exbtn1)) ||
9248
3/4
✓ Branch 0 taken 1621051 times.
✓ Branch 1 taken 770 times.
✓ Branch 2 taken 1621051 times.
✗ Branch 3 not taken.
1621821 (zc_getrawkey(Exkey2, true)||joybtn(Exbtn2)) ||
9249
2/4
✓ Branch 0 taken 1621051 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1621051 times.
✗ Branch 3 not taken.
1621051 (zc_getrawkey(Exkey3, true)||joybtn(Exbtn3)) ||
9250
2/2
✓ Branch 0 taken 1621032 times.
✓ Branch 1 taken 19 times.
1621051 (zc_getrawkey(Exkey4, true)||joybtn(Exbtn4))) // Skipping joystick axes
9251 50489904 return true;
9252
9253 1621032 return false;
9254 6510614 }
9255
9256 108529366 bool getInput(int32_t btn, bool press, bool drunk, bool ignoreDisable, bool eatEntirely, bool peek)
9257 {
9258 108529366 bool ret = false, drunkstate = false, rawret = false;
9259 108529366 bool* flag = &down_control_states[btn];
9260
2/7
✓ Branch 0 taken 102011933 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 6517433 times.
108529366 switch(btn)
9261 {
9262 case btnF12:
9263 ret = zc_getkey(KEY_F12, ignoreDisable);
9264 rawret = zc_getrawkey(KEY_F12, ignoreDisable);
9265 eatEntirely = false;
9266 break;
9267 case btnF11:
9268 ret = zc_getkey(KEY_F11, ignoreDisable);
9269 rawret = zc_getrawkey(KEY_F11, ignoreDisable);
9270 eatEntirely = false;
9271 break;
9272 case btnF5:
9273 ret = zc_getkey(KEY_F5, ignoreDisable);
9274 rawret = zc_getrawkey(KEY_F5, ignoreDisable);
9275 eatEntirely = false;
9276 break;
9277 case btnQ:
9278 ret = zc_getkey(KEY_Q, ignoreDisable);
9279 rawret = zc_getrawkey(KEY_Q, ignoreDisable);
9280 eatEntirely = false;
9281 break;
9282 case btnI:
9283 ret = zc_getkey(KEY_I, ignoreDisable);
9284 rawret = zc_getrawkey(KEY_I, ignoreDisable);
9285 eatEntirely = false;
9286 break;
9287 case btnM:
9288
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6517433 times.
6517433 if(FFCore.kb_typing_mode) return false;
9289 6517433 rawret = ret = zc_getrawkey(KEY_ESC, ignoreDisable);
9290 6517433 eatEntirely = false;
9291 6517433 break;
9292 default: //control_state[] index
9293
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102011933 times.
102011933 if(FFCore.kb_typing_mode) return false;
9294
5/6
✓ Branch 0 taken 101784203 times.
✓ Branch 1 taken 227730 times.
✓ Branch 2 taken 2257162 times.
✓ Branch 3 taken 99527041 times.
✓ Branch 4 taken 2257162 times.
✗ Branch 5 not taken.
102011933 if(!ignoreDisable && get_bit(quest_rules, qr_FIXDRUNKINPUTS) && disable_control[btn]) drunk = false;
9295
2/2
✓ Branch 0 taken 5491613 times.
✓ Branch 1 taken 96520320 times.
102011933 else if(btn<11) drunkstate = drunk_toggle_state[btn];
9296
4/4
✓ Branch 0 taken 91845546 times.
✓ Branch 1 taken 10166387 times.
✓ Branch 2 taken 1395 times.
✓ Branch 3 taken 10164992 times.
112178320 ret = control_state[btn] && (ignoreDisable || !disable_control[btn]);
9297 102011933 rawret = raw_control_state[btn];
9298 102011933 }
9299
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 108529366 times.
108529366 assert(flag);
9300
2/2
✓ Branch 0 taken 70505419 times.
✓ Branch 1 taken 38023947 times.
108529366 if(press)
9301 {
9302
2/2
✓ Branch 0 taken 1337132 times.
✓ Branch 1 taken 36686815 times.
38023947 if(peek)
9303 1337132 ret = rButtonPeek(ret, *flag);
9304
3/4
✓ Branch 0 taken 36686815 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17001122 times.
✓ Branch 3 taken 19685693 times.
36686815 else if (replay_is_active() && replay_get_version() < 8) ret = rButton(ret, *flag);
9305 17001122 else ret = rButton(ret, *flag, &rawret);
9306 38023947 }
9307
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 108529366 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
108529366 if(eatEntirely && ret) control_state[btn] = false;
9308
3/4
✓ Branch 0 taken 82010678 times.
✓ Branch 1 taken 26518688 times.
✓ Branch 2 taken 82010678 times.
✗ Branch 3 not taken.
108529366 if(drunk && drunkstate) ret = !ret;
9309 108529366 return ret;
9310 108529366 }
9311
9312 5384201 byte getIntBtnInput(byte intbtn, bool press, bool drunk, bool ignoreDisable, bool eatEntirely, bool peek)
9313 {
9314 5384201 byte ret = 0;
9315
2/2
✓ Branch 0 taken 4045008 times.
✓ Branch 1 taken 1339193 times.
5384201 if(intbtn & INT_BTN_A) ret |= getInput(btnA, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_A : 0;
9316
2/2
✓ Branch 0 taken 5383639 times.
✓ Branch 1 taken 562 times.
5384201 if(intbtn & INT_BTN_B) ret |= getInput(btnB, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_B : 0;
9317
2/2
✓ Branch 0 taken 5383764 times.
✓ Branch 1 taken 437 times.
5384201 if(intbtn & INT_BTN_L) ret |= getInput(btnL, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_L : 0;
9318
2/2
✓ Branch 0 taken 5383764 times.
✓ Branch 1 taken 437 times.
5384201 if(intbtn & INT_BTN_R) ret |= getInput(btnR, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_R : 0;
9319
2/2
✓ Branch 0 taken 5383764 times.
✓ Branch 1 taken 437 times.
5384201 if(intbtn & INT_BTN_EX1) ret |= getInput(btnEx1, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX1 : 0;
9320
2/2
✓ Branch 0 taken 5383764 times.
✓ Branch 1 taken 437 times.
5384201 if(intbtn & INT_BTN_EX2) ret |= getInput(btnEx2, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX2 : 0;
9321
2/2
✓ Branch 0 taken 5383764 times.
✓ Branch 1 taken 437 times.
5384201 if(intbtn & INT_BTN_EX3) ret |= getInput(btnEx3, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX3 : 0;
9322
2/2
✓ Branch 0 taken 5383764 times.
✓ Branch 1 taken 437 times.
5384201 if(intbtn & INT_BTN_EX4) ret |= getInput(btnEx4, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX4 : 0;
9323 5384201 return ret; //No early return, to make sure all button presses are eaten that should be! -Em
9324 }
9325
9326 1114 byte checkIntBtnVal(byte intbtn, byte vals)
9327 {
9328 1114 return intbtn&vals;
9329 }
9330
9331 1281348 bool Up()
9332 {
9333 1281348 return getInput(btnUp);
9334 }
9335 77421 bool Down()
9336 {
9337 77421 return getInput(btnDown);
9338 }
9339 167324 bool Left()
9340 {
9341 167324 return getInput(btnLeft);
9342 }
9343 188659 bool Right()
9344 {
9345 188659 return getInput(btnRight);
9346 }
9347 68115 bool cAbtn()
9348 {
9349 68115 return getInput(btnA);
9350 }
9351 1255212 bool cBbtn()
9352 {
9353 1255212 return getInput(btnB);
9354 }
9355 bool cSbtn()
9356 {
9357 return getInput(btnS);
9358 }
9359 29891 bool cLbtn()
9360 {
9361 29891 return getInput(btnL);
9362 }
9363 29891 bool cRbtn()
9364 {
9365 29891 return getInput(btnR);
9366 }
9367 bool cPbtn()
9368 {
9369 return getInput(btnP);
9370 }
9371 bool cEx1btn()
9372 {
9373 return getInput(btnEx1);
9374 }
9375 bool cEx2btn()
9376 {
9377 return getInput(btnEx2);
9378 }
9379 bool cEx3btn()
9380 {
9381 return getInput(btnEx3);
9382 }
9383 bool cEx4btn()
9384 {
9385 return getInput(btnEx4);
9386 }
9387 bool AxisUp()
9388 {
9389 return getInput(btnAxisUp);
9390 }
9391 bool AxisDown()
9392 {
9393 return getInput(btnAxisDown);
9394 }
9395 bool AxisLeft()
9396 {
9397 return getInput(btnAxisLeft);
9398 }
9399 bool AxisRight()
9400 {
9401 return getInput(btnAxisRight);
9402 }
9403
9404 bool cMbtn()
9405 {
9406 return getInput(btnM);
9407 }
9408 bool cF12()
9409 {
9410 return getInput(btnF12);
9411 }
9412 bool cF11()
9413 {
9414 return getInput(btnF11);
9415 }
9416 bool cF5()
9417 {
9418 return getInput(btnF5);
9419 }
9420 bool cQ()
9421 {
9422 return getInput(btnQ);
9423 }
9424 bool cI()
9425 {
9426 return getInput(btnI);
9427 }
9428
9429 112876 bool rUp()
9430 {
9431 112876 return getInput(btnUp, true);
9432 }
9433 112804 bool rDown()
9434 {
9435 112804 return getInput(btnDown, true);
9436 }
9437 112757 bool rLeft()
9438 {
9439 112757 return getInput(btnLeft, true);
9440 }
9441 112309 bool rRight()
9442 {
9443 112309 return getInput(btnRight, true);
9444 }
9445 2482 bool rAbtn()
9446 {
9447 2482 return getInput(btnA, true);
9448 }
9449 113491 bool rBbtn()
9450 {
9451 113491 return getInput(btnB, true);
9452 }
9453 5266505 bool rSbtn()
9454 {
9455 5266505 return getInput(btnS, true);
9456 }
9457 6510614 bool rMbtn()
9458 {
9459 6510614 return getInput(btnM, true);
9460 }
9461 112109 bool rLbtn()
9462 {
9463 112109 return getInput(btnL, true);
9464 }
9465 112106 bool rRbtn()
9466 {
9467 112106 return getInput(btnR, true);
9468 }
9469 5182404 bool rPbtn()
9470 {
9471 5182404 return getInput(btnP, true);
9472 }
9473 bool rEx1btn()
9474 {
9475 return getInput(btnEx1, true);
9476 }
9477 bool rEx2btn()
9478 {
9479 return getInput(btnEx2, true);
9480 }
9481 122985 bool rEx3btn()
9482 {
9483 122985 return getInput(btnEx3, true);
9484 }
9485 122985 bool rEx4btn()
9486 {
9487 122985 return getInput(btnEx4, true);
9488 }
9489 bool rAxisUp()
9490 {
9491 return getInput(btnAxisUp, true);
9492 }
9493 bool rAxisDown()
9494 {
9495 return getInput(btnAxisDown, true);
9496 }
9497 bool rAxisLeft()
9498 {
9499 return getInput(btnAxisLeft, true);
9500 }
9501 bool rAxisRight()
9502 {
9503 return getInput(btnAxisRight, true);
9504 }
9505
9506 bool rF11()
9507 {
9508 return getInput(btnF11, true);
9509 }
9510 bool rQ()
9511 {
9512 return getInput(btnQ, true);
9513 }
9514 bool rI()
9515 {
9516 return getInput(btnI, true);
9517 }
9518
9519 13317771 bool DrunkUp()
9520 {
9521 13317771 return getInput(btnUp, false, true);
9522 }
9523 12417217 bool DrunkDown()
9524 {
9525 12417217 return getInput(btnDown, false, true);
9526 }
9527 7866450 bool DrunkLeft()
9528 {
9529 7866450 return getInput(btnLeft, false, true);
9530 }
9531 6829749 bool DrunkRight()
9532 {
9533 6829749 return getInput(btnRight, false, true);
9534 }
9535 5759186 bool DrunkcAbtn()
9536 {
9537 5759186 return getInput(btnA, false, true);
9538 }
9539 5722928 bool DrunkcBbtn()
9540 {
9541 5722928 return getInput(btnB, false, true);
9542 }
9543 5152193 bool DrunkcEx1btn()
9544 {
9545 5152193 return getInput(btnEx1, false, true);
9546 }
9547 5152213 bool DrunkcEx2btn()
9548 {
9549 5152213 return getInput(btnEx2, false, true);
9550 }
9551 bool DrunkcSbtn()
9552 {
9553 return getInput(btnS, false, true);
9554 }
9555 bool DrunkcMbtn()
9556 {
9557 return getInput(btnM, false, true);
9558 }
9559 bool DrunkcLbtn()
9560 {
9561 return getInput(btnL, false, true);
9562 }
9563 bool DrunkcRbtn()
9564 {
9565 return getInput(btnR, false, true);
9566 }
9567 bool DrunkcPbtn()
9568 {
9569 return getInput(btnP, false, true);
9570 }
9571
9572 bool DrunkrUp()
9573 {
9574 return getInput(btnUp, true, true);
9575 }
9576 bool DrunkrDown()
9577 {
9578 return getInput(btnDown, true, true);
9579 }
9580 bool DrunkrLeft()
9581 {
9582 return getInput(btnLeft, true, true);
9583 }
9584 bool DrunkrRight()
9585 {
9586 return getInput(btnRight, true, true);
9587 }
9588 4315794 bool DrunkrAbtn()
9589 {
9590 4315794 return getInput(btnA, true, true);
9591 }
9592 4328323 bool DrunkrBbtn()
9593 {
9594 4328323 return getInput(btnB, true, true);
9595 }
9596 71669 bool DrunkrEx1btn()
9597 {
9598 71669 return getInput(btnEx1, true, true);
9599 }
9600 71662 bool DrunkrEx2btn()
9601 {
9602 71662 return getInput(btnEx2, true, true);
9603 }
9604 bool DrunkrEx3btn()
9605 {
9606 return getInput(btnEx3, true, true);
9607 }
9608 bool DrunkrEx4btn()
9609 {
9610 return getInput(btnEx4, true, true);
9611 }
9612 bool DrunkrSbtn()
9613 {
9614 return getInput(btnS, true, true);
9615 }
9616 bool DrunkrMbtn()
9617 {
9618 return getInput(btnM, true, true);
9619 }
9620 4832892 bool DrunkrLbtn()
9621 {
9622 4832892 return getInput(btnL, true, true);
9623 }
9624 4830254 bool DrunkrRbtn()
9625 {
9626 4830254 return getInput(btnR, true, true);
9627 }
9628 bool DrunkrPbtn()
9629 {
9630 return getInput(btnP, true, true);
9631 }
9632
9633 6819 void eat_buttons()
9634 {
9635 6819 getInput(btnA, true, false, true);
9636 6819 getInput(btnB, true, false, true);
9637 6819 getInput(btnS, true, false, true);
9638 6819 getInput(btnM, true, false, true);
9639 6819 getInput(btnL, true, false, true);
9640 6819 getInput(btnR, true, false, true);
9641 6819 getInput(btnP, true, false, true);
9642 6819 getInput(btnEx1, true, false, true);
9643 6819 getInput(btnEx2, true, false, true);
9644 6819 getInput(btnEx3, true, false, true);
9645 6819 getInput(btnEx4, true, false, true);
9646 6819 }
9647
9648 // Is true for the _first frame_ of a key press.
9649 // But! it is possible that a script manually sets the value of KeyPress,
9650 // in which case it will be restored to the "true" value based on `key_current_frame`
9651 // and `key_previous_frame` on the next frame.
9652 14 bool zc_readkey(int32_t k, bool ignoreDisable)
9653 {
9654
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(ignoreDisable) return KeyPress[k];
9655
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 switch(k)
9656 {
9657 case KEY_F7:
9658 case KEY_F8:
9659 case KEY_F9:
9660 return KeyPress[k];
9661
9662 default:
9663
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 1 times.
14 return KeyPress[k] && !disabledKeys[k];
9664 }
9665 14 }
9666
9667 // Is true for _every frame_ a key is held down.
9668 // But! it is possible that a script manually sets the value of KeyInput,
9669 // in which case it will be restored to the "true" value based on `key_current_frame`
9670 // on the next frame.
9671 bool zc_getkey(int32_t k, bool ignoreDisable)
9672 {
9673 if(ignoreDisable) return KeyInput[k];
9674 switch(k)
9675 {
9676 case KEY_F7:
9677 case KEY_F8:
9678 case KEY_F9:
9679 return KeyInput[k];
9680
9681 default:
9682 return KeyInput[k] && !disabledKeys[k];
9683 }
9684 }
9685
9686 // Reads (and then clears) the current frame key state directly.
9687 // Scripts can also modify `key_current_frame`.
9688 125 bool zc_readrawkey(int32_t k, bool ignoreDisable)
9689 {
9690
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 123 times.
125 if(zc_getrawkey(k, ignoreDisable))
9691 {
9692 2 _key[k]=key[k]=key_current_frame[k]=0;
9693 2 return true;
9694 }
9695 123 _key[k]=key[k]=key_current_frame[k]=0;
9696 123 return false;
9697 125 }
9698
9699 // Reads the current frame key state directly.
9700 // Scripts can also modify `key_current_frame`.
9701 43497761 bool zc_getrawkey(int32_t k, bool ignoreDisable)
9702 {
9703
2/2
✓ Branch 0 taken 36987119 times.
✓ Branch 1 taken 6510642 times.
43497761 if(ignoreDisable) return key_current_frame[k];
9704
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6510642 times.
6510642 switch(k)
9705 {
9706 case KEY_F7:
9707 case KEY_F8:
9708 case KEY_F9:
9709 return key_current_frame[k];
9710
9711 default:
9712
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6510642 times.
6510642 return key_current_frame[k] && !disabledKeys[k];
9713 }
9714 43497761 }
9715
9716 // Only used for a handful of keys, like tilde and Function keys.
9717 // This state is never read within the game.
9718 // It exists so that all keyboard input still functions during replay,
9719 // without inadvertently doing things like toggling throttling if the player
9720 // presses ~
9721 13021293 bool zc_get_system_key(int32_t k)
9722 {
9723 13021293 return key_system[k];
9724 }
9725
9726 // True for the _first_ frame of a key press.
9727 58595526 bool zc_read_system_key(int32_t k)
9728 {
9729 58595526 return key_system_press[k];
9730 }
9731
9732 826847978 bool is_system_key(int32_t k)
9733 {
9734
2/2
✓ Branch 0 taken 768252452 times.
✓ Branch 1 taken 58595526 times.
826847978 switch (k)
9735 {
9736 case KEY_BACKQUOTE:
9737 case KEY_CLOSEBRACE:
9738 case KEY_END:
9739 case KEY_HOME:
9740 case KEY_OPENBRACE:
9741 case KEY_PGDN:
9742 case KEY_PGUP:
9743 case KEY_TAB:
9744 case KEY_TILDE:
9745 58595526 return true;
9746 }
9747 768252452 return is_Fkey(k);
9748 826847978 }
9749
9750 6510614 void update_system_keys()
9751 {
9752
2/2
✓ Branch 0 taken 826847978 times.
✓ Branch 1 taken 6510614 times.
833358592 for (int32_t q = 0; q < 127; ++q)
9753 {
9754
2/2
✓ Branch 0 taken 136722894 times.
✓ Branch 1 taken 690125084 times.
826847978 if (!is_system_key(q))
9755 690125084 continue;
9756
9757 136722894 key_system[q] = key[q];
9758
1/2
✓ Branch 0 taken 136722894 times.
✗ Branch 1 not taken.
136722894 key_system_press[q] = key_system[q] && !key_system_previous[q];
9759 136722894 key_system_previous[q] = key_system[q];
9760 136722894 }
9761 6510614 }
9762
9763 7628080 void update_keys()
9764 {
9765
2/2
✓ Branch 0 taken 968766160 times.
✓ Branch 1 taken 7628080 times.
976394240 for (int32_t q = 0; q < 127; ++q)
9766 {
9767 // When replaying, replay.cpp takes care of updating `key_current_frame`.
9768
1/2
✓ Branch 0 taken 968766160 times.
✗ Branch 1 not taken.
968766160 if (!replay_is_replaying())
9769 key_current_frame[q] = key[q];
9770
9771
2/2
✓ Branch 0 taken 961653306 times.
✓ Branch 1 taken 7112854 times.
968766160 KeyPress[q] = key_current_frame[q] && !key_previous_frame[q];
9772 968766160 KeyInput[q] = key_current_frame[q];
9773 968766160 key_previous_frame[q] = key_current_frame[q];
9774 968766160 }
9775 7628080 }
9776
9777 bool zc_disablekey(int32_t k, bool val)
9778 {
9779 switch(k)
9780 {
9781 case KEY_F7:
9782 case KEY_F8:
9783 case KEY_F9:
9784 return false;
9785
9786 default:
9787 disabledKeys[k] = val;
9788 return true;
9789 }
9790 }
9791
9792 void zc_putpixel(int32_t layer, int32_t x, int32_t y, int32_t cset, int32_t color, int32_t timer)
9793 {
9794 timer=timer;
9795 particles.add(new particle(zfix(x), zfix(y), layer, cset, color));
9796 }
9797
9798 // these are here so that copy_dialog won't choke when compiling zelda
9799 int32_t d_alltriggerbutton_proc(int32_t, DIALOG*, int32_t)
9800 {
9801 return D_O_K;
9802 }
9803
9804 int32_t d_comboa_radio_proc(int32_t, DIALOG*, int32_t)
9805 {
9806 return D_O_K;
9807 }
9808
9809 int32_t d_comboabutton_proc(int32_t, DIALOG*, int32_t)
9810 {
9811 return D_O_K;
9812 }
9813
9814 int32_t d_ssdn_btn_proc(int32_t, DIALOG*, int32_t)
9815 {
9816 return D_O_K;
9817 }
9818
9819 int32_t d_ssdn_btn2_proc(int32_t, DIALOG*, int32_t)
9820 {
9821 return D_O_K;
9822 }
9823
9824 int32_t d_ssdn_btn3_proc(int32_t, DIALOG*, int32_t)
9825 {
9826 return D_O_K;
9827 }
9828
9829 int32_t d_ssdn_btn4_proc(int32_t, DIALOG*, int32_t)
9830 {
9831 return D_O_K;
9832 }
9833
9834 int32_t d_sslt_btn_proc(int32_t, DIALOG*, int32_t)
9835 {
9836 return D_O_K;
9837 }
9838
9839 int32_t d_sslt_btn2_proc(int32_t, DIALOG*, int32_t)
9840 {
9841 return D_O_K;
9842 }
9843
9844 int32_t d_sslt_btn3_proc(int32_t, DIALOG*, int32_t)
9845 {
9846 return D_O_K;
9847 }
9848
9849 int32_t d_sslt_btn4_proc(int32_t, DIALOG*, int32_t)
9850 {
9851 return D_O_K;
9852 }
9853
9854 int32_t d_ssrt_btn_proc(int32_t, DIALOG*, int32_t)
9855 {
9856 return D_O_K;
9857 }
9858
9859 int32_t d_ssrt_btn2_proc(int32_t, DIALOG*, int32_t)
9860 {
9861 return D_O_K;
9862 }
9863
9864 int32_t d_ssrt_btn3_proc(int32_t, DIALOG*, int32_t)
9865 {
9866 return D_O_K;
9867 }
9868
9869 int32_t d_ssrt_btn4_proc(int32_t, DIALOG*, int32_t)
9870 {
9871 return D_O_K;
9872 }
9873
9874 int32_t d_ssup_btn_proc(int32_t, DIALOG*, int32_t)
9875 {
9876 return D_O_K;
9877 }
9878
9879 int32_t d_ssup_btn2_proc(int32_t, DIALOG*, int32_t)
9880 {
9881 return D_O_K;
9882 }
9883
9884 int32_t d_ssup_btn3_proc(int32_t, DIALOG*, int32_t)
9885 {
9886 return D_O_K;
9887 }
9888
9889 int32_t d_ssup_btn4_proc(int32_t, DIALOG*, int32_t)
9890 {
9891 return D_O_K;
9892 }
9893
9894 int32_t d_tri_edit_proc(int32_t, DIALOG*, int32_t)
9895 {
9896 return D_O_K;
9897 }
9898
9899 int32_t d_triggerbutton_proc(int32_t, DIALOG*, int32_t)
9900 {
9901 return D_O_K;
9902 }
9903
9904 /*** end of zc_sys.cc ***/
9905
9906